I’m wishing to trigger a function to pause my project (game) on the html target, whenever it’s obvious that the game isn’t being played. then unpause if the user returns to it.
In flash it used to be straighforward, listen to Event.DEACTIVATE, Event.ACTIVATE, the use of these events when compiling to the html target give mixed results, and in many browsers dont fire when you expect them too (e.g. minimising the browser / opening addition browser windows etc)
I’ve been directed by a html progrmmer to read up on the “Page Visibility API” , the visibilitychange event fires at obvious times, and document.hidden / document.visibilityState can be queried to discover the state of view of the game.
I’d really like to know how i could use this api, or query the document.visibility state within my code, as i’ve no idea how to reference the document directly from within openfl. any help greatly appreciated.