Skip to content

Instantly share code, notes, and snippets.

@amacdougall
Created July 12, 2011 15:15
Show Gist options
  • Save amacdougall/1078176 to your computer and use it in GitHub Desktop.
Save amacdougall/1078176 to your computer and use it in GitHub Desktop.
Mouse return focus detector
import com.alanmacdougall.underscore._;
// and then, after View is added to stage...
stage.addEventListener(Event.MOUSE_LEAVE, function handleMouseLeave(event:Event):void {
stage.removeEventListener(Event.MOUSE_LEAVE, handleMouseLeave);
stage.addEventListener(MouseEvent.MOUSE_OVER, function handleMouseReturn(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_LEAVE, handleMouseReturn);
// wait 500ms to let other handlers sort themselves out, I guess
_(function():void {
trace("Mouse has returned; current keyboard-focused DisplayObject is " + stage.focus);
}).delay(500);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment