views:

153

answers:

1

Hi,

I'm using the Actionscript Timer class. What happens if I run a function every 3 seconds, but the function takes 4 seconds to complete?

Does the Timer object queue up events? I guess this must happen if only 1 thread is being used?

+1  A: 

All the events will be fired - if the script takes more time to run than the delay, the timings will be offset as required and you will not get the desired output.

From the page you linked:

Depending on the SWF file's framerate or Flash Player's environment (available memory and other factors), Flash Player may dispatch events at slightly offset intervals. For example, if a SWF file is set to play at 10 frames per second [fps], which is 100 millisecond intervals, but your timer is set to fire an event at 80 milliseconds, Flash Player will fire the event close to the 100 millisecond interval. Memory-intensive scripts may also offset the events.

Amarghosh