setInterval(func, 1000)
What if the func
takes longer than 1000
ms, will the next call wait for 1000
ms or execute right away?
setInterval(func, 1000)
What if the func
takes longer than 1000
ms, will the next call wait for 1000
ms or execute right away?
The callback method will be invoked every 1000ms if there's nothing much else going on.
I have half a piece of code written out to elaborate a way to call an interval every 1000ms, and depending on a boolean value the interval re-invokes or deletes itself. Let me know if you want me to paste.
Edit: See answer from bhups, much better description - still let me know if you want that code I mentioned.
Flash runtime is single threaded. So whenever there is an action to perform (a function call) then it get queued to the already pending actions. So at any point of time only one function is being executed.
In your case If you function func
is taking more than 1000 ms to execute i.e. if func
is in between its execution and time interval expires a new call to func
is queued. So as soon as first func
is finished executing then the next call will be picked if there is any. In this case it will be another func
call. If there were other listener which were called before this then they will be called in order.