/ Published in: ActionScript 3
URL: http://www.adamcoulombe.info/lab/as3/Arrange.html
DEMO: http://www.adamcoulombe.info/lab/as3/Arrange.html FLA: http://www.adamcoulombe.info/lab/as3/Arrange.fla
Some prototype functions that give you easy Bring to Front / Send to Back / Bring Forward / Send Backwards functionality in Flash AS3
Expand |
Embed | Plain Text
MovieClip.prototype.bringToFront = function():void { this.parent.setChildIndex(this, this.parent.numChildren-1); } MovieClip.prototype.sendToBack = function():void { this.parent.setChildIndex(this, 0); } MovieClip.prototype.bringForward = function():void{ var currentDepth = this.parent.getChildIndex(this); if(currentDepth<this.parent.numChildren-1){ this.parent.setChildIndex(this, currentDepth+1); } } MovieClip.prototype.sendBackward = function():void{ var currentDepth = this.parent.getChildIndex(this); if(currentDepth>0){ this.parent.setChildIndex(this, currentDepth-1); } } /* blue.addEventListener(MouseEvent.MOUSE_UP, clicked); green.addEventListener(MouseEvent.MOUSE_UP, clicked); orange.addEventListener(MouseEvent.MOUSE_UP, clicked); function clicked(e:MouseEvent){ e.target.sendBackward(); //you also could say... // e.target.sendBackward(); // e.target.bringForward(); // e.target.sendToBack(); // e.target.bringToFront(); } */
You need to login to post a comment.
