1 Reply Latest reply on Apr 1, 2012 2:09 AM by ShardulSingh

    How to swap element layer?

    Yue_Hong

      In flex when we key in something like this:

       

      <s:Image id="pic" source="image/a.jpg" smooth="true"/>

      <s:Image id="pic2" source="image/b.jpg"  smooth="true"/>

       

      The pic2 will be on top of pic. How can I have pic on top of pic 2? I have tried using swap element (this.swapChildren(pic,pic2)), but it doesn't work. Any help is very appreciated. Thanks.

        • 1. Re: How to swap element layer?
          ShardulSingh Level 3

          Hi,

           

          Create a method like below and use that:-

           

          protected function yourSwap():void

                      {

                          var topLevelChildrenIndex : int = yourContainer.numChildren -1;

                          yourContainer.setElementIndex(yourContainer.getElementAt(topLevelChildrenIndex),0);

                      }

           

           

          Here your 'yourContainer' is the id of the component the children of which you want to swap.In your requirement this is the id of the container which is having your images.

           

           

           

          Hope this will help.

           

           

           

          with Regards,

          Shardul Singh

          1 person found this helpful