PDA

View Full Version : Swap depth in flash



Majumderit
May 15th, 2008, 06:33 AM
Hi i have a file where 16 movie clips. i need to drag and drop ecah of everyone. But the problem is when i drag it's not coming infront of all clips. I need when i will drag a clip it become infront of all clips. Could you help to to do this plzzzzzzzzzzzz.

bluemagica
May 15th, 2008, 06:47 AM
it depends on how the rest of your code work but in this case you can do

this.swapDepths(-99)

therobot
May 15th, 2008, 08:36 AM
it depends on how the rest of your code work but in this case you can do

this.swapDepths(-99)


// AS2
this.onPress = function ()
{
this.startDrag();
this.swapDepths(parentMC.getNextHighestDepth());
}

Majumderit
May 16th, 2008, 03:36 AM
Thanks, It's working now.

dreko90
April 14th, 2011, 05:53 PM
Incase anyone is looking to apply this effect to dynamically created movie clips put out on the stage, here is an example. It will bring any mc that is selected to the very top.

for (var i:Number = 0; i < 5; i++) {
//attachMovie without a target mc will put these on the stage
attachMovie("box_mc", "newBox"+(i+1), i, {_x:xPos, _y:yPos});
}

_root["newBox"+(i+1)].onPress = function() {
//THIS being the selected mc, and root targeting the main stage
this.swapDepths(_root.getNextHighestDepth());
}