5 Replies Latest reply on Oct 26, 2008 7:19 AM by Newsgroup_User

    TypeError: Error #1009: Issue

    PastaPrimavera
      I placed a TabNavigator with 2 tabs, labeled Main, Line1.
      On the main page I have several TextInput boxes, I also have TextInput boxes on the Line1 page as well.

      I have a created a public function called "public function Line1Refresh():void". In there all I do is initialize the TextInput boxes with default values until it can connect to my sever and get the real data.
      I.E. L1.text= "Please Wait";

      In the parameters for Line1, I have added the "Line1RefreshI();" call to the Creation Complete option so that when the page is done rendering, it will call this function and fill in the blanks.
      I have the same for the Main page as well initializing the TextInputs on that page as well.

      OK..... Now for the problem.....

      When the Main page is finished rendering and it called MainRefresh(); I initialize the TextInputs in there with no problems.

      All worked fine until I decided to also initialize the TextInput fields in the Line1 page.
      When I did that I got a :

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at Index/ParseReceivedData()[G:\Flex3\Index\src\Index.mxml:412]
      at Index/onData()[G:\Flex3\Index\src\Index.mxml:170]

      Anyone know what's the deal here, why I cannot access items on a different page ?


        • 1. Re: TypeError: Error #1009: Issue
          m_hartnett Level 3
          Objects in Flex are not created until they are needed. The objects in your second tab are not yet created.

          You can put creationPolicy="all" in your object definition and that will cause all objects to be created when the parent object is created.

          You can also use the event listener 'change' of the tab object to initialize objects on the tab pages. This technique requires checking for the tab page that is now visible and executing tab page specific code. However this technique allows for the page to be displayed faster to the user.

          If there are very few objects on the page then either the creationPolicy and change event listener would be fine to use.
          • 2. Re: TypeError: Error #1009: Issue
            PastaPrimavera Level 1
            Thanks for the quick reply and solution!!!
            • 3. Re: TypeError: Error #1009: Issue
              ntsiii Level 3
              Don't get in the habit of using creationPolicy="all". You will regret it one day.

              Tracy
              • 4. Re: TypeError: Error #1009: Issue
                m_hartnett Level 3
                I agree with Tracy 100% on this. You should only use creationPolicy="all" when absolutely necessary.

                One thing I left out of my original answer was to use binding for initialization of datafields. If you have a form or label/text data to display on the screen then bind their text attributes to some source object and populate the source object in the initialization process and all of your screen and form objects will have the initialized values automatically.

                • 5. Re: TypeError: Error #1009: Issue
                  Level 7

                  "mhartnett" <webforumsuser@macromedia.com> wrote in message
                  news:ge1snh$prl$1@forums.macromedia.com...
                  >I agree with Tracy 100% on this. You should only use creationPolicy="all"
                  >when
                  > absolutely necessary.
                  >
                  > One thing I left out of my original answer was to use binding for
                  > initialization of datafields. If you have a form or label/text data to
                  > display
                  > on the screen then bind their text attributes to some source object and
                  > populate the source object in the initialization process and all of your
                  > screen
                  > and form objects will have the initialized values automatically.

                  For more detail on this, see Q5
                  http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf