How can I run code in Actionscript 3 when a page with my flash object is... well... I'm not sure of the term.
When the webpage is left and the flash applet is exited?
How can I run code in Actionscript 3 when a page with my flash object is... well... I'm not sure of the term.
When the webpage is left and the flash applet is exited?
I would suggest that if the reason for running code on page leave is to communicate with a server and/or you are making a game to be put up on other portals and you cannot modify their javascript, save whatever you need to save every X seconds, or better, every time something major changes (eg you competed a level / new highscore). This way, if your game/browser/os crashes progress is not lost.
I don't think Flash has built-in functionality to catch this type of event. You might try a javascript solution. See this topic. By doing so, you could implement a flash object callback using Flash's ExternalInterface at the time the user leaves your page.