被点击mc可以拖动 自动到最上层

/*舞台上有三个mc*/

import flash.events.MouseEvent;



mc1.addEventListener(MouseEvent.MOUSE_DOWN,_onMouseDown);

mc2.addEventListener(MouseEvent.MOUSE_DOWN,_onMouseDown);

mc3.addEventListener(MouseEvent.MOUSE_DOWN,_onMouseDown);



mc1.addEventListener(MouseEvent.MOUSE_UP,_onMouseUp);

mc2.addEventListener(MouseEvent.MOUSE_UP,_onMouseUp);

mc3.addEventListener(MouseEvent.MOUSE_UP,_onMouseUp);



function _onMouseDown(e:MouseEvent):void

{

	//trace(e.target.parent.numChildren-1)

	e.target.startDrag();

	e.target.parent.setChildIndex(e.target,e.target.parent.numChildren-1);

}



function _onMouseUp(e:MouseEvent):void

{

	e.target.stopDrag();

}



你可能感兴趣的:(自动)