Search code examples
apache-flexdirectionhbox

How do I change a box components direction in Flex 3?


With mx:Box I can set the direction to be either "horizontal" or "vertical". I'd like to reverse the order of the components in the box though. For example:

before:

|button1| |button2| |button3|

after:

|button3| |button2| |button1|

I've created a custom component that lives in a mx:Box and would like to do this in as simplest a way as possible.

Any help appreciated,

Many thanks,

Bryn


Solution

  • The simplest that comes to mind is to override the addChild method in Box:

    import mx.containers.Box;
    
    public class ReverseBox extends Box
    {
      public override function addChild(child:flash.display.DisplayObject):flash.display.DisplayObject
      {
        return addChildAt(child, 0);
      }
    }
    

    hth

    Koen