AS3でonDragOver, onDragOut, onReleaseOutsideを実現する

AS2であった
onDragOver
onDragOut
onReleaseOutside
というマウスイベントがAS3ではとれない。

それを実現する方法

button.addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
button.addEventListener(MouseEvent.MOUSE_UP, buttonRelease);
button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver);
button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut);

function buttonPress(e:MouseEvent):void {
//the button is pressed, set a MOUSE_UP event on the button's parent stage
//to caputre the onReleaseOutside event.
button.parent.stage.addEventListener(MouseEvent.MOUSE_UP, buttonRelease);
}

function buttonRelease(e:MouseEvent):void {
//remove the parent stage event listener
button.parent.stage.removeEventListener(MouseEvent.MOUSE_UP, buttonRelease);

//if the events currentTarget doesn't equal the button we
//know the mouse was released outside.
if (e.currentTarget != button) {
trace('onReleasedOutside');
} else {
//the events currentTarget property equals the button instance therefore
//the mouse was released over the button.
trace('onRelease');
}
}

function buttonOver(e:MouseEvent):void {
if (e.buttonDown) {
//if the mouse button is selected when the cursor is
//over our button trigger the onDragOver functionality
trace('onDragOver');
} else {
//if the mouse button isn't selected trigger the standard
//onRollOver functionality
trace('onRollOver');
}
}

function buttonOut(e:MouseEvent):void {
if (e.buttonDown) {
//if the mouse button is selected when the cursor is
//moves off of our button trigger the onDragOut functionality
trace('onDragOut');
} else {
//if the mouse button isn't selected trigger the standard
//onRollOut functionality
trace('onRollOut');
}
}

参考:http://www.scottgmorgan.com/blog/index.php/2007/12/20/ondragover-ondragout-and-onreleaseoutside-in-as3/