Swapping Depths in AS3

Swapping depths in Actionscript 2 style was easy, you simply typed

this.swapDepths(this._parent.getNextHighestDepth())

and you were up and running. Not so with AS3, the getNextHighestDepth() is gone. The alternative is the 'setChildIndex' which is applied to the container Sprite/MovieClip/UIContainer or whatever container you may be using. IN this case I had a UIComponent names 'thumbs'. It held a number of UIComponents named "thumbs" + x.
In order to swap depths I used this

var box:UIComponent = getChildByName('thumbs');
box['setChildIndex'] (box.getChildByName('thumbs0'), box['numChildren'] - 1);


0 comments:

My Instagram