2 Replies Latest reply on Jun 28, 2007 8:47 PM by journeydude

    Drawing order of components

    journeydude Level 1
      Is there a way in MXML to specify drawing order? I'm relatively new and the only thing I can see in MXML to specify drawing order is to declare the components in the order you want them drawn. Let's say I have two panels, p1 and p2, and one extra state s2. What would I put in s2 to make p1 appear on TOP of p2 in s2???

      <mx:State name="s2">


      <mx:Panel x="10" y="10" width="250" height="200" layout="absolute" id="p1" title="Panel 1">
      <mx:Panel x="40" y="40" width="250" height="200" layout="absolute" id="p2" title="Panel 2">

      Thanks much in advance
        • 1. Re: Drawing order of components
          peterent Level 2
          You are correct in that drawing order is related to the order in which components are added to the display list. That's the default behavior using the addChild() method of a container. You can also use addChildAt( child, index ) to specify a position.

          If the children are already in place you can swap their positions or move one child into a specific position. For example, if you have two children, the positions are 0 and 1. If you want 1 to become zero, then use setChildIndex( child, 0 ) and that component will be moved behind all others.

          Doing this in a state change is difficult since the order isn't a property of the child, you must execute a function. I suggest just doing it in ActionScript either before or after you switch states.
          • 2. Re: Drawing order of components
            journeydude Level 1
            Thanks I'll give it a try. ;-)