1 Reply Latest reply on Apr 11, 2009 7:59 AM by ergo_eleven

    Advice re: the <mx:TextInput> control

    jcahill23 Level 1

      Hi. I have created a tab navigator with 6 tabs in a <mx:WindowedApplication>.

      Each tab is a canvas in which sits a text input control.

              <mx:Canvas id="tab0" width="613" height="397" borderColor="#737373">
                  <mx:TextInput x="42" y="134" width="193" id="labelName2" fontFamily="Georgia" />        


      I don't seem to be able to access/set the labelName0.text from within the <mx:Script> block.

      I thought all flex controls are public instances and their properties can be accessed from anywhere in the code.


      What I am trying to do is listen for the "closing" event on WindowedApplication and then put all text inputs into an array which I will then save using AIR and can be reloaded into the text input controls when the app is started again.

      But the error message I keep getting is: "Cannot access a property or method of a null object reference."

      It's driving me nuts!



        • 1. Re: Advice re: the <mx:TextInput> control

          You problem is that you trying to access to object that doesn't created for the time being.

          I.e. the TextArea has not yet created. TabNavigator (and others components) creats its children only when it needed (when you switched on particular tab in case TabNavigator). The shortest way to solve this: set creationPolicy="all" for TabNavigator.

          Try to run this code (with and without creationPolicy):


                      public function init():void
                         text="text 1" />
                    text="text 2" />
                         text="text 3" />


          It will work, but the elegant way to figure out this problem (IMHO) is to create a public string properties and bind TextArea to it.


                   destination="text1" />
               text="{text1}" />



          When you will read/write componet state, you will refer to text1 property, and you must know nothing about labelName0.text.