yoolek as3 flash cms

30Mar/090

swap depth() in as3

AS3 SwapDepths Equivalent
as2 to as3 swapDepths()
action script 3 swap depths

This movie requires Flash Player 9

download


function SwapDepths(e:MouseEvent):void {
	var target=e.target;
	this.setChildIndex(target, (this.numChildren - 1));
 
}
this.addEventListener(MouseEvent.MOUSE_DOWN, SwapDepths);

if you add child from library you can use this code:

var one:One=new One();
one.x=150;
one.y=150;
 
var two:Two=new Two();
two.x=200;
two.y=150;
 
var three:Three=new Three();
three.x=175;
three.y=200;
 
this.addChild(one);
this.addChild(two);
this.addChild(three);
 
function doSwapDepths(e:MouseEvent):void {
	addChild(MovieClip(e.target));
}
this.addEventListener(MouseEvent.MOUSE_DOWN, doSwapDepths);

Tagged as: , No Comments