Actionscript:
-
mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
-
function onRollOver(evt:MouseEvent):void {
-
addChild(MovieClip(evt.currentTarget));
-
}
This one is very simple, but it's important to note that using addChild() on something that is already on the display list simply brings it to the top. Back in AS2 we used to do:
Actionscript:
-
mc.swapDepths(1000);
3 Comments
I saw Lee Brimelow first use this a while back and have been using it ever since. It’s a great little trick.
Yeah its a good one. When I first started with AS3 I thought that doing this might add the clip a second time… sort of like what duplicateMovieClip used to be.
Lee Brimelow’s stuff is great. I really like the two pixel bender tutorials.
Interesting. I usually use this:
[code]
public static function moveToTop(obj:Object):void
{
obj.parent.setChildIndex(obj as DisplayObject, obj.parent.numChildren - 1);
}
[/code]