Intervals are not a problem as long as you use them correctly.

Just make sure for every setInterval() call you have a corresponding
clearInterval() call.  Usually the clearInterval() is within your interval
event handler function, so once the interval end condition is met, there's
no way for your code to exit without hitting it.

//PSEUDOCODE
var myInterval = setInterval(myFunc, 200);

myFunc(){
  //do stuff
  if(endCondition == true){
     clearInterval(myInterval);
  }
}

I've been doing things this way for a long time, and I can't even remember
the last time that I had a runaway interval problem.  There's no need for an
IntervalManager class if you don't want to deal with that.  (Nothing wrong
with it, but it might be overkill.)

Of course onEnterFrame is fine too if you're doing something in the context
of a MovieClip, but that may not always be the case.  And with that there's
a danger that you need to look out for: if a MovieClip already has an
onEnterFrame handler, you could overwrite it...

-Adam

On 2/28/07, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote:

> So even though I never wrote it I would offer the following
> advice, which is to *almost* not use setInterval at all.

Hogwash.

http://www.kennybunch.com/index.php?p=16

:)
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to