I've found anecdotally the onEnterFrames are less CPU intensive than a
setInterval running at a similar rate.

The cons of setInterval are worth noting, but if you're using a good OOP
code design, and you're strict about tracking your interval IDs, then you
don't have to be too afraid of setInterval.  I usually define a single
member variable in a class to track a particular interval.  Any time I want
to call set interval, I first make sure the interval is cleared.

...
if(this.intervalId)
  clearInterval(this.intervalId);
this.intervalId = setInterval(this, "someMethod", time);

Seems to work pretty well.

There is also a gotcha related to onEnterFrame that's worth mentioning: A
MovieClip can only have a single onEnterFrame handler, so when you assign an
event handler to some MovieClip you'd better make sure it doesn't already
have a  different onEnterFrame already assigned to it.  I've run into this
kind of thing when working with animations from artists who like to put a
lot of Actionscript functionality into their MovieClips.

-Adam

On 5/24/06, Rifled Cloaca <[EMAIL PROTECTED]> wrote:

Flashcoders,

I'm building a modular system that contains various programmatic
animations
within seperate modules, coordinated by a central wrapper class.  I've
opted
to use empty movieclips with onEnterFrame functions to manage timing in
animations and presentation playback, as opposed to setInterval.  Reason
being is that I don't want to have to worry about scoping my intervals,
and
most of all, losing track of intervals and eventually having them stack
up,
interfere with eachother, and cause memory leaks.

Question is, isn't it more processor intensive to use a series of
onEnterFrames like this?  Can anyone think of any other cons to the method
I've chosen?

Thanks in advance!
-g
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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