4Apr/090
swap depths + attachMovie in as3
AS3 SwapDepths Equivalent + attachMovie
as2 to as3 swapDepths() +attachMovie
action script 3 swap depths attach movie
create movie clip with linkage "Box"
This movie requires Flash Player 9
function SwapDepths(e:MouseEvent):void { this.setChildIndex(Box(e.target), (this.numChildren - 1)); } function addBoxes():void { for (var i:int = 0; i <3; i++) { var colorTransform:ColorTransform = new ColorTransform(); colorTransform.color = (Math.random() * 0xFFFFFF); var box:Box = new Box(); box.x = ((i * 50) + 5); box.y = ((i * 20) + 5); box.transform.colorTransform = colorTransform; box.buttonMode = true; box.addEventListener(MouseEvent.MOUSE_DOWN, SwapDepths); this.addChild(box); } } addBoxes();
30Mar/090
swap depth() in as3
AS3 SwapDepths Equivalent
as2 to as3 swapDepths()
action script 3 swap depths
This movie requires Flash Player 9
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);
