move clip to top level
I've got a movieclip containing another movieclip which acts as a button. The movieclip has a drag function added to it.
function onBoxPress( event:MouseEvent ):void
{
var boundsRect:Rectangle = new Rectangle(event.currentTarget.x,0,0,stage.height);
event.currentTarget.startDrag(false, boundsRect);
}
//;
function onBoxRelease( event:MouseEvent ):void
{
event.currentTarget.stopDrag();
sortBoxes();
}
On the stage I've got several copies of this clip. It works ok: when I click and drag, the clip drags vertically. However, each clip has its own depth and sometimes a clip will drag beneath another clip. So upon clicking and dragging the clip should be moved to the top level of all duplicate clips.
How do I move it to the front of all other clips?
I've tried using:
function onBoxPress( event:MouseEvent ):void
{
setChildIndex(event.currentTarget.parent,0)
var boundsRect:Rectangle = new Rectangle(event.currentTarget.x,0,0,stage.height);
event.currentTarget.startDrag(false, boundsRect);
}
I use event.currentTarget.parent here because the clip to have it's index set is the parent clip. Remember, the button which starts it all is inside that parent clip.
But then I get an error 2025:
Error #2025: The supplied DisplayObject must be a child of the caller