[AS3 SNIPPET] Detect if Flash movie gain/lose focus
1 2 3 4 5 6 7 8 9 10 11 12 | stage.addEventListener(Event.ACTIVATE, activateHandler); stage.addEventListener(Event.DEACTIVATE, deactivateHandler); function activateHandler(event:Event):void { trace("activateHandler"); } function deactivateHandler(event:Event):void { trace("deactivateHandler"); } |
Event.ACTIVATE is dispatched when the Flash Player or AIR application gains operating system focus and becomes active.
Event.DEACTIVATE is dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.
Sadly this doesn’t work in all browsers see here
Hi Al,
I hope that after two years something has been fixed. From what I know there aren’t problems on the Win platform and this affects only some version of Safari on Mac.
Usually I was using this event for optimization issues, nothing that can cause big problems if not executed.
If you want to be sure that the code is executed you can use the Event.MOUSE_LEAVE / MouseEvent.MOUSE_MOVE combination as explained in this post.
Thanks for the tips!
I’m working on a 3D API (see http://directflex.net) and performances are always an issue. It’s just dumb to take the whole CPU power for an application thaht does not have the focus
Thx again!
[AS3 SNIPPET] Detect if Flash movie gain/lose focus http://hex.io/18ge #as3 #flash
This comment was originally posted on Twitter
[AS3 SNIPPET] Detect if Flash movie gain/lose focus http://bit.ly/q7Wmd
This comment was originally posted on Twitter
Adobe AIR News: [AS3 SNIPPET] Detect if Flash movie gain/lose focus: 123456// Dispatched when the.. http://tinyurl.com/kpe2em
This comment was originally posted on Twitter