Monday, September 10, 2007
MOUSE_LEAVE annoyance
Monday, September 10, 2007
AS3 gives us the MOUSE_LEAVE event when listened for, and its really quite handy and something we have been clamoring for as developers for a long while. However, it does not respond if you perform a mouse press & drag outside the stage (until the mouse comes back up). So it would seem like the event is really a MOUSE_UP when the mouse it outside the bounds of the stage. You can take care of your UI stuff at that point, but I wish we could get this even regardless of whether the mouse was down or not.
import flash.events.MouseEvent;
import flash.events.Event;
import flash.ui.Mouse;
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
function mouseMoveHandler(event:MouseEvent):void{
Mouse.hide();
cursor.visible = true;
cursor.x = stage.mouseX;
cursor.y = stage.mouseY;
}
function mouseLeaveHandler(event:Event):void{
Mouse.show();
cursor.visible = false;
}
Comments:
There are currently 5 Comments:
-
Tony Fendall said...“Sounds to me like you're looking for MouseEvent.MOUSE_OUT
This one does what you're looking for, but I have found a small bug where the event doesn't fire is the user is moving their mouse slowly (less than 10px per second or so).”




