1 Reply Latest reply on Jan 31, 2010 11:21 PM by Flex harUI

    AddChild() problem - child doesn't apper at runtime

    beynar

      I've got very simple class which takes on constructor ArrayCollection of images and adding each one item using AddChild method, here is a code of this class:

       

      package jb
      {
          import mx.collections.ArrayCollection;
          import mx.containers.HBox;
          import mx.controls.Image;
      
          public class SliderItemsContainerAS extends HBox
          {
              public function SliderItemsContainerAS(imagesCollection:ArrayCollection)
              {
                  super();
                  setStyle("backgroudColor", "0x429323");
                  
                  for each(var image:Image in imagesCollection)
                  {
                      addChild(image);
                  }
              }
          }
      }
      

       

      Then I creating 2 instance of this class in main application file and of course provide correct images collection. Finally I'm adding the objects to Application.

       

                  private function loadAllImagesComplete():void
                  {
                      var itemsContainer:SliderItemsContainerAS = new SliderItemsContainerAS(imagesStack);
                      var itemsContainer2:SliderItemsContainerAS = new SliderItemsContainerAS(imagesStack);
                                      
                      addChild(itemsContainer2);
                      addChild(itemsContainer);
                  }
      

       

       

      PROBLEM: Only one of added objects (SliderItemsContainerAS) display nested images, why?

      I make a little investigation and when I add somethink else than my Image e.g. Label created in SliderItemsContainerAS constructor it's appers in both instance of the display object.

       

      I'm attaching main application file where you can see the way I retriving images.