5 Replies Latest reply on Mar 3, 2010 8:37 PM by Gregory Lafrance

    Getting the TypeError #1009

    Learningflex003

      Hello All,

      I'm receiving a message I can't seem to find the answer for. I did the research in the forums but couldn't find anything to help resolve this error message.

       

      Its a new applicaion. the applicaion basically has the following containers and controlers:

      View stack

      linkbutton

      containters

      text input fields

      one button

       

      As of now my applicaion is pretty empty.The alert i placed inside the initapp function appears after i click either the dismiss all or continue button found on the flash player.

       

      Any ideas?

       

      Problem area:

      public  function initApp():void
         { Alert.show('Im inside initApp');
           savebutton.addEventListener(MouseEvent.CLICK, saveuserinformation);
         }

       

      public function saveuserinformation(event:MouseEvent):void
        {  Alert.show('You clicked the SAve user info button');  } // this doesnt work

       

       

       

      the button which is initiating the call:

      <mx:Button label="Submit my information" id="savebutton" fontSize="12"/>

       

      error message:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at servicebid/initApp()[C:\wamp\www\ContractAid\src\servicebid.mxml:11]
      at servicebid/___servicebid_Application1_creationComplete()[C:\wamp\www\ContractAid\src\serv icebid.mxml:3]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()

        • 1. Re: Getting the TypeError #1009
          Arun Lal

          Where are you calling the initApp() function??  it should be called on crerationComplete event of the Application. Try it and let me know if it helps

          • 2. Re: Getting the TypeError #1009
            Gregory Lafrance Level 6

            Probably the savebutton is in a view of the ViewStack, but not in the first view.

             

            ViewStack creates the children of its views as each view is accessed.

             

            You can set the creationPolicy property of the ViewStack to "all". This is not best practice if there are many views with lots of UI in the views, but this may be an acceptable workaround for you.

             

            If this post answers your question or helps, please mark it as such.


            Greg Lafrance - Flex 2 and 3 ACE certified

            www.ChikaraDev.com

            Flex / AIR Development, Training, and Support Services

            • 3. Re: Getting the TypeError #1009
              Learningflex003 Level 1

              Hello  Flashwhizz,

               

              Thanks for the suggestion and answer.

              heres the application tag and yes i did have the creationcompete in the tag...

               

               

              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1024"
                      height="800" creationComplete="initApp()">

               

              more ideas welcome.

               

              • 4. Re: Getting the TypeError #1009
                Learningflex003 Level 1

                Hello Greg,

                 

                Thanks for the reply back.

                 

                Question.

                If your suggestion isnt the best practice what is the best practice for what Im doing.

                Im sure im not the only one who has a button in the second. linkbar.

                 

                Is there a better way to access/control a button controler from a sec. or third viewstack ?

                • 5. Re: Getting the TypeError #1009
                  Gregory Lafrance Level 6

                  I believe the best practice is to pre-initialize controls that you need to access before those "non-first" ViewStack views are initialized.

                   

                  This would be done in ActionScript in a <Script> block creationComplete or perhaps initialize event handler.

                   

                  I think after initialization they would be added to the view in question.

                   

                  If this post answers your question or helps, please mark it as such.


                  Greg Lafrance - Flex 2 and 3 ACE certified

                  www.ChikaraDev.com

                  Flex / AIR Development, Training, and Support Services