The swapDepth is not available on AS3, rather much more simplest way is available.
The below commented code can be achieved through the single line:
event.target.parent.addChild(event.target);
private var _dragIcon:MovieClip;
dragIcon.addEventListener(MouseEvent.MOUSE_UP,onMouseUp, false, 0, true);
dragIcon.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown, false, 0, true);/*
private var oldSwapDepth:int = 0;
private var tempSwapDepth:int = 0;
private function onMouseDown(event:MouseEvent):void
{
dragIcon.startDrag(false)
tempSwapDepth = dragIcon.parent.getChildIndex(dragIcon);
var newSwapDepth:int = dragIcon.parent.getChildIndex(swapDepthMc);
newSwapDepth>oldSwapDepth ? newSwapDepth = newSwapDepth : newSwapDepth = oldSwapDepth;
dragIcon.parent.setChildIndex(dragIcon,newSwapDepth)
oldSwapDepth = dragIcon.parent.getChildIndex(dragIcon);
}
private function onMouseUp(event:MouseEvent):void {
dragIcon.stopDrag();
dragIcon.parent.setChildIndex(dragIcon,tempSwapDepth);
} */
private function onMouseDown(event:MouseEvent):void
{
event.target.parent.addChild(event.target);
}

September 2, 2008 at 3:25 am |
Well,
you can also use setChildIndex()
I had some problems in Flex when using addChild() again and again, and I found that setChildIndex works properly in those cases.
September 3, 2008 at 4:11 am |
[...] Read more [...]