I don’t want to breed ill will by playing Actionscript favorites, but at the moment I definitely like Event.MOUSE_LEAVE a little more than the rest of the flash.events.Event types.
I’m working on a piece of functionality in my Flash as3 application that involves replacing the mouse cursor with a custom clip and making another clip change it’s position in response to MouseEvent.MOUSE_MOVE. The standard cursor is supposed to return and everything stops dragging on MouseEvent.MOUSE_UP. Standard stuff that any Flash developer has worked with before. What left me unsatisfied was detecting MOUSE_UP when the user has dragged the cursor off of the swf entirely. In this case the dragging action is still active until the user has brought the mouse back to the stage and clicked a couple times. There are all kinds of schemes from as2 for detecting position and watching for when the user leaves the stage, but they tend to break with rapid movements. Generally a hackfest of complex answers.
Enter my favorite new Event type:
It took me awhile of hunting around in the API Livedocs to find this gem, in part because I was focused on using MouseEvent for my solution and wasn’t looking at the main Event class. Interestingly enough, it appears in my case that the event is not dispatched until the user lets go of the mouse, so it’s more of a MOUSE_UP while offstage, but that’s the end result I wanted so now I’m satisfied.
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.