Which one is better for code that should repeat at at intervals, onEnterFrame or setInterval?
onEnterFrame
- the rate of execution changes with the movie’s frame rate – good for animation, bad otherwise
- causes a screen to be redrawn on completion – good for animation
setInterval
- the interval is independent of a movie’s frame rate – good for scrollbars and the like
- screen must be updated manually at the end of each interval (in addition to screen redraws called by onEnterFrame) – not so good for animation
- the interval is counted from when an iteration’s code has executed to before the next iteration’s start executing. If the code takes long to execute, the interval is not quite what expected