PDA

View Full Version : May i use setInterval ?


X_Cli
03-25-2006, 10:11 AM
Hello,

Well, i am wondering about the use of the setInterval method.

I'm currently working on a game in AS, and to make the animation(make things move, make the collision tests etc..) and i'm not sure to choose the good method.

It appears there is two methods to do recurrent tasks :

* Use onEnterFrame and a loop (gotoAndPlay()) to go back to this frame
* Use the setInterval method


Which one is the best ?

I've heard onEnterFrame is quite slow and that itss major drawback is that the synchronization is based on the framerate of the animation ... (i suppose it tell that if i increase the framerate of the animation to make it fluid, it will speed up the whole thing)

On the contrary, setInterval is told to be source of problems that make things to be asynchrone. However the advantages are well known.

What is the best ? Or if there is no universal answer, what is the best for a game :confused: