2 Replies Latest reply on Apr 19, 2007 8:08 AM by Nerun

    Initialization of Child components

      Hello there,

      I'm working my way into the Flex world and i seem to have an understanding problem you guys might be able to help with.

      I created a custom MXML component that is derived from VBox. It holds some custom elements like a few ViewStacks and some other boxes.

      Now I tried to make a new instance of such a component in my class to add it as child to a tab navigator.
      var newTab:myBox = new myBox();

      The result is that i get the box, but all of it's child components (viewstacks and such) are not initialized (=null) and cannot be accessed.
      Needless to say that my next step myBox.initialize(); didn't help much either.

      I'd be gratefull for any help you can offer to make me understand this problem. Even a crisp RTFM with a link to a thread here or the manual will be more than welcome. ;)

      Thx a lot in advance!
        • 1. Re: Initialization of Child components
          peterent Level 2
          The TabNavigator has a creationPolicy of "auto" by default. This means it will fully create the first child and partially create the rest of its children. Try setting creationPolicy="all" on the TabNavigator. This tells the TabNavigator that you want the children fully created.

          You can also force the TabNavigator to fully create the children by calling createComponentsFromDescriptors(true) after each child (unless you are adding them all at once, such as a loop, then call this once as it is an expensive call to make).

          The reason for "auto" is to make start-up faster and only create the children as the user visits them. This also applies to the other navigator controls like ViewStack and Accordion.
          • 2. Re: Initialization of Child components
            Nerun Level 1
            thx a bunch, that did the trick.