views:

141

answers:

1

I have a flash/Actionscript 3 application (swf). This application sends a message to a server every 2 seconds. However, in some browsers/operating systems (for example, safari in mac), the moment the browser loses focus, it stops sending these messages.

I send these messages in a EVENT.ENTER_FRAME loop, so every time the application is rendered I have the chance to send a message. My theory is that some browsers apperantly stop callling this method/stop rendering for some reason, because it has lost focus. However, I want to keep sending these messages.

I already tried to use a Timer, an event that would be called every 2 seconds, but I read somewhere (and my tests seem to agree) that this timer is also connected to the rendering/frame entering, so that timed function will also not be executed.

Is there a way to do what I want?

+2  A: 

You can use the MOUSE_LEAVE stage event to check when your swf has lost focus.

What I would recommend is using the ExternalInterface to establish a connection between the swf and javascript. As soon as the connection is done, have javascript call your server instead of flash, that may loose focus.

Out of curiosity, why would you need to poll the server every 2 seconds ?

George Profenza