Detect when the mouse leaves the movie.

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I previous of flash there was no way to detect when the users mouse had left the flash movie.

Actionscript 3 now allows you to detect when the users mouse has left the movie using the mouseLeave event.

Lets take a look:

package {
    import flash.events.Event;
    import flash.events.MouseEvent;

    public class mouseLeaveTest extends Sprite {

        public function mouseLeaveTest() {
            stage.addEventListener(Event.MOUSE_LEAVE, mouseHasLeft);
        }

        public function mouseHasLeft)(e:Event):void {
            trace('Mouse have left the stage');
        }

    }
}


4 Responses to “Detect when the mouse leaves the movie.”

  1. Brian Davis says:

    odd, this doesn’t seem to work during dragging…

  2. admin says:

    I will look into a solution for this

  3. I can’t get it to work while dragging either. Bummer.

  4. pooya says:

    what’s happen in AS2 ????

Leave a Reply

Close
E-mail It