Posted By

Winkyboy on 07/29/10


addChild addChildAt SwapChildren

Versions (?)

Who likes this?

4 people have marked this snippet as a favorite


AS3 GetNextHighestDepth

 / Published in: ActionScript 3

Often used in conjunction with dragging elements around the screen, you may want the item most recently picked up to jump to the top of the "stack." Here's how to do it. In the event handler you create, you tell the item's parent to set its child's index to the highest number of its children.

  1. private function YourHandlerFunction(e:MouseEvent):void {
  2. e.currentTarget.parent.setChildIndex(DisplayObject(e.currentTarget), e.currentTarget.parent.numChildren - 1);
  3. e.currentTarget.startDrag();
  4. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: konrad_ha on May 17, 2011

Brilliant, I have to look this up every time. Thanks a lot.

You need to login to post a comment.