Question

I have an AIR Desktop Game that has background music and in the main menu repeating animations. Is there an inbuilt possibility to tell the AIR container, that when the window loses focus (e.g. through alt+tab or when pressing the windows key), that the AIR container is then pausing the content of its container (pausing music and animations/frameHandlers etc.)?

Or is it only possible by stopping all contents one by one and when getting focus again, start all things one by one?

Was it helpful?

Solution

What @JoshJanusch said is true -- you will have to manage it yourself, though setting stage.frameRate might help in your case.

Most activate/deactivate managers I've seen do some of the following:

  • Set stage.frameRate to 0.01 (slows animations and ENTER_FRAME event listeners, saving CPU/battery especially on mobile)
  • Stop sounds (if you play all sounds through some SoundManager class, this may be easy)
  • Manage your use of setInterval or setTimeout as they're Timers that continue to fire
  • Consider suspending any other asynchronous activity (like network requests or background Workers)

Feel free to make suggestions for this list in the comments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top