Archive for April 13th, 2008

13
Apr

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');
        }

    }
}

Found this useful? How about buying me a coffee - simply click here.




Close
E-mail It