Revision: 5116
Updated Code
at February 12, 2008 12:04 by chrisaiv
Updated Code
var button:Sprite = new Sprite(); button.graphics.beginFill(0x000000, 1); button.graphics.drawRect(50,50,200,100); button.buttonMode = true; button.addEventListener(MouseEvent.MOUSE_DOWN, buttonPress); button.addEventListener(MouseEvent.MOUSE_UP, buttonRelease); button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); addChild(button); function buttonPress(e:MouseEvent):void { trace(e.currentTarget.parent.parent + " == " + stage); stage.addEventListener(MouseEvent.MOUSE_UP, buttonRelease); } function buttonRelease(e:MouseEvent):void { //Remove the Stage listener created on buttonPress stage.removeEventListener(MouseEvent.MOUSE_UP, buttonRelease); //The Mouse was released outside the target Box if (e.currentTarget != button) { trace('onReleasedOutside'); } else { //The Mouse was released inside the target Box trace('onRelease'); } } function buttonOver(e:MouseEvent):void { //The user is dragging something to the target object if (e.buttonDown) { //The state is MOUSE_DOWN trace('onDragOver'); } else { //The state is MOUSE_UP trace('onRollOver'); } } function buttonOut(e:MouseEvent):void { //The user is dragging something from the target object if (e.buttonDown) { //The state is MOUSE_DOWN trace('onDragOut'); } else { //The state is MOUSE_UP trace('onRollOut'); } }
Revision: 5115
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 12, 2008 12:01 by chrisaiv
Initial Code
var button:Sprite = new Sprite(); button.graphics.beginFill(0x000000, 1); button.graphics.drawRect(50,50,200,100); button.buttonMode = true; button.addEventListener(MouseEvent.MOUSE_DOWN, buttonPress); button.addEventListener(MouseEvent.MOUSE_UP, buttonRelease); button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); addChild(button); function buttonPress(e:MouseEvent):void { button.parent.stage.addEventListener(MouseEvent.MOUSE_UP, buttonRelease); } function buttonRelease(e:MouseEvent):void { //Remove the Stage listener created on buttonPress button.parent.stage.removeEventListener(MouseEvent.MOUSE_UP, buttonRelease); //The Mouse was released outside the target Box if (e.currentTarget != button) { trace('onReleasedOutside'); } else { //The Mouse was released inside the target Box trace('onRelease'); } } function buttonOver(e:MouseEvent):void { //The user is dragging something to the target object if (e.buttonDown) { //The state is MOUSE_DOWN trace('onDragOver'); } else { //The state is MOUSE_UP trace('onRollOver'); } } function buttonOut(e:MouseEvent):void { //The user is dragging something from the target object if (e.buttonDown) { //The state is MOUSE_DOWN trace('onDragOut'); } else { //The state is MOUSE_UP trace('onRollOut'); } }
Initial URL
http://www.scottgmorgan.com/blog/index.php/2007/12/20/ondragover-ondragout-and-onreleaseoutside-in-as3/
Initial Description
Scott Morgan figured out a beautiful way to offer the AS2 Mouse Event onReleaseOutside.
Initial Title
AS3: onDragOver, onDragOut, onReleaseOutside
Initial Tags
Initial Language
ActionScript 3