views:

16

answers:

2

I am looking for a consistent way to determine when Flash is going to be unloaded. I need to handle this event in order to call a tracking API once rather than each analytical event.

Any suggestions on how to consistently (across all browsers) handle this would be really helpful and much appreciated.

Thanks in advance.

A: 

I dont think there is a good way to do in only in flash.
I would use ExternalInterface.addCallback in order to register a flash function as a javascript callback. And then using javascript i would listen to the onbeforeunload event and call that function.

Tjelle
A: 

There is no consistent or guaranteed way to achieve this. Some browsers may send an event, but in the end flash has no way of knowing its about to be killed, so you're better off designing your app that in mind.

The best way as far as I know is to have a heartbeat in your client that polls the server every x seconds to let it know it is still there. So when the server doesn't receive an update in time it can assume that the client is killed and do the cleanup on the server side.

Would love to know of a better solution, but so far none appear to exist.

jpop