Posted By

visualadvance on 08/11/09


Tagged

actionscript event activate 3 as3 deactivate


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

solo1artist
Pingpongbal
DualBrain
TrentSkunk
davidino1978
tspitzr
adrianparr


AS3: Stage Focus


 / Published in: ActionScript 3
 

Lets you know if you are off the flash movie. Handy for when games lose focus so you can pause it. Please note that this doesn't work in all browsers properly.

  1. stage.addEventListener(Event.ACTIVATE, flashActive);
  2. stage.addEventListener(Event.DEACTIVATE, flashDeactive);
  3.  
  4. private function flashActive (event:Event):void
  5. {
  6. trace("flash gained focus");
  7. }
  8.  
  9. private function flashDeactive (event:Event):void
  10. {
  11. trace("flash lost focus");
  12. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mpineault on February 5, 2010

This only seems to work if you click on the swf and click off the swf video when working in flash.

Doesn't seem to work with respects to hovering on or off the swf file.

Posted By: visualadvance on April 11, 2010

Yeah this wouldn't respond to hover. Flash only loses focus when being clicked out of.

You need to login to post a comment.