2 Replies Latest reply on Jan 28, 2010 6:51 PM by stangyk

    "Lazy"/Delayed initialization of objects?

    stangyk

      Good day!

      I have a Text control just for easy debugging during development, it was setup as follows:

       

                  <!--some previous forms here not shown-->

                  </mx:Form>
                  <mx:Form id="DebugResults" label="Debug Output" hideEffect="{fadeOut}" showEffect="{fadeIn}" >
                      <mx:Text x="128" y="500" enabled="true" id="DebugResultsTXT" width="570"
                          text="debugging output here" />
                  </mx:Form>
              </mx:TabNavigator>

       

      And an event handler that outputs the debugging info:

       

                  public function debug_handleReply(event:ResultEvent):void
                  {
                      // writes to the Text Control for easy debugging
                      if(DebugResultsTXT){
                          DebugResultsTXT.text = event.result.toString();
                      }
                  }

       

      My problem is that when the webpage loads, DebugResultsTXT is always NULL. (I set breakpoint and watched DebugResultsTXT)  I found out that I need to manually navigate to the tab "DebugResults" and the DebugResultsTXT text control will be instantiated.

       

      My Questions:

      (1) is this because flash performs "lazy" or delayed initialization/instantiation of objects?

      (2) any way to "force" the instantiation of DebugResultsTXT without having to manually navigate to that tab (can't expect that from the end-user right?)

       

      Many thanks!