[HTML5] Window without focus


I am experiencing a weird problem with my particle system: when the application window is visible everything runs ok, but when it is not visible anymore the app switches to a sort of limbo, where something continues running and something freezes automatically.
Usually this is a bearable thing, and it is good for mobile devices that have to spare on battery, but in the case my particle system is running and I keep the app offscreen for more than… i.e. 1 minute, when I revive the window the app hangs for a few seconds as if it was trying to catch up with the undrawn particles that was skipped/paused when the app was not visible.

Is there a way to manually control how the app behaves when it looses the focus?


I think there is a FOCUS event somewhere (as in as3). You could change the framerate or stop everything when focus is lost.
I don’t know how your particle system works, but if it relies on Lib.getTimer(), maybe the problem is that (=> low framerate but your time is wrong).


Well, I’d like to simply pause the particle generation.
I will search for focus event, I hope this is sufficient, thanks @loudo

EDIT: I have added ACTIVATE/DEACTIVATE and FOCUS_IN/FOCUS_OUT events to Stage.
What I need is not focus, because it is related to i.e. a button: if I bring up the app window I have a FOCUS_IN event, but if I click on a part of the window where there is not this button I obtain a FOCUS_OUT event, and the situation does not change until I click the button, even if I hide and bring back up the window.
On the contrary ACTIVATE/DEACTIVATE trigger correctly when I change/hide the app window and select/show/set it as the current window.