As2 to as3 swap depth movieclips

actionscript-3flash

I have two movieclips on stage and I want to change which mc appear in front of another
I've read and there are two ways for that setChildIndex and swapChildren methods but in all the tutorials I've read about is you can change the depths if they are in a sprite but I cannot use sprite
how can I do it with movieclips???

Best Answer

This would be the same for MovieClips as well. the two methods you mentioned, setChildIndex() and swapChildren() are methods of DisplayObjectContainer and work with DisplayObjects as the arguments. Since both MovieClip and Sprite inherit from DisplayObject, both will work identically.

These are both correct:

stage.swapChildren(mySprite1, mySprite2);
stage.swapChildren(myMovieClip1, myMovieClip2);

As are these:

stage.setChildIndex(mySprite, 1);
stage.setChildIndex(myMovieClip, 1);
Related Topic