views:

19

answers:

3

Hello,

i have a bunch of movieclips on the stage and some are nested into others, i would like to have 1 of them to be put on top of everything else on the stage when i start dragging it. Anyone know how to get a nested movieclip on top of parents etc?

A: 

Suppose, Container is your parent movieClip and it has many children then Now your target and currentTarget property depends on which object the listener is attached and how much you have nested your movieclips. in my case the Container is your parent movieClip having two or more children.

Container.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);

public function pickUp(param1:MouseEvent) : void {

            var objectToDrag =  param1.target; 
            Container.setChildIndex(param1.target,Container.numChildren-1);
            objectToDrag.startDrag(true);
        }
Muhammad Irfan
A: 

top of everything else on stage:

stage.addChild(target);
OXMO456
A: 

You could have a top layer & a bottom layer , whenever you want to add a child on top of everything else, simply add the child to the top layer. This way you don't need to figure what the parent position is , just keep this layer on top for that specific purpose.

var topLayer:Sprite = new Sprite();
var bottomLayer:Sprite = new Sprite();
var childMc:MovieClip; // the mc you want to have on top

//somewhere in your code...
childMc.addEventListener(MouseEvent.MOUSE_DOWN , childMcMouseDownListener );

addChild( bottomLayer );
addChild( topLayer );

//add everything to the bottom layer
//leave the topLayer empty until you add the child mc
//add the following code in your MouseDown Listener

function childMcMouseDownListener(event:MouseEvent ):void
{
   topLayer.addChild( event.currentTarget );
}
PatrickS