Running Code on page leave [Actionscript]

221 Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

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.