0 Replies Latest reply on Sep 15, 2009 7:43 AM by BIOSMonkey

    Navigator deferred instantiation not working when added to state?

    BIOSMonkey

      I have a large application that is driven by states (init, login, and gui).

       

      The gui state contains a large viewstack representing the different "pages" that show depending on menu selection.

       

      I have had a major performance problem for quite some time because I noted that ALL children of the viewstack were being instantiated (I have init code tied to the creationComplete event of the child components).  This did not make sense to me because of the way that deferred instantiation is supposed to work.

       

      Well, today I finally found that the reason is because of the state and using mx:AddChild.

       

      If for example I create a simple project with a tab navigator, 3 canvases and trace the preinit, init, and creationcomplete events I get this:

       

      Canvas 1 preinit
      Canvas 2 preinit
      Canvas 3 preinit
      Canvas 1 init
      Canvas 1 creationComplete

       

      as expected.

       

      But now if I create a state, use AddChild to add the tab navigator to the state, and activate the state, I get this:

       

      Canvas 1 preinit
      Canvas 1 init
      Canvas 2 preinit
      Canvas 2 init
      Canvas 3 preinit
      Canvas 3 init
      Canvas 1 creationComplete
      Canvas 2 creationComplete
      Canvas 3 creationComplete

       

      So it would seem that using AddChild breaks deferred instantiation in navigation containers??

       

      This is a pretty big problem, does anyone have some idea why this is happening and how to fix it?

       

      Thanks