Search code examples
javascriptactionscript-3eventsfocusstage

Flash: Coming back from another tab in browser, can flash listen to return to tab event of some sort?


I got this flash application where you can click a link while watching a video. It will open a new tab and pause the video. Now when you come back to the flash application it would be nice if the video would start playing again. Is there a way, an event or so to do this ?


Solution

  • I think i have solved it like this:

    I listen to a mouse_leave event on the stage, because your mouse will leave the stage when in another tab. (or at least, you have to click a tab to get back to the flash, so you always end up outside of the flash). When you left the stage a stageLeave boolean is set to true.

    Then I have another event listener, mouse_move that sets the stageLeave boolean to false (when true) and dispatches a custom STAGE_RETURN event.

    The only sidenote here is that you'll have to move with the mouse over the stage to make the video play again. But that's something you will do anyway.