Event.MOUSE_LEAVE is great in Actionscript 3, but it doesn’t seem to fire if the user is holding their left (or right for that matter) mouse button down.
Is there a way to detect if the mouse leaves the Flash movie while the mouse is held down? Or if it is released outside the flash movie?
To get all of that requires a little bit of a hack. You have to store whether the mouse is off the stage or not and handle the
Event.MOUSE_LEAVEevent accordingly. Doing it this way gives you all the normal mouse functionality including not stopping the drag just because the mouse went off stage. Since the user might come back on stage and continue the drag it waits ’til the user releases the mouse either on or off stage.The hack is that the
MOUSE_LEAVEevent, not theMOUSE_UPevent, gets fired when the mouse is released off stage so you have to keep track of whether or not the mouse was already off stage when it was released.after the drag is finished you of course want to remove all the event listeners associated with detecting mouse-outs and mouse-ups but that code was left out for readability.