Flash Optimizations of onClip enterFrame events

Thursday, September 25th, 2008 | Business

I’m going to be writing up a tutorial and exploring the benefits of what I am about to propose, this is for conversation and discussion.

When creating MovieClip objects that update their status every frame they enter, traditionally you bind a general loop to their “onClipEvent(enterFrame)” or other methods to bind to the onEnterFrame method.

Inside is normally a loop that executes perpetually with each frame refresh.  When objects build up with this logic, the framerate in Flash movies can dwindle.  This is especially evident on slower functioning computers.

I will be testing out a method to enhance movieclips who don’t need to always be looping.  For example, if you have a navigational structure with 3 elements.  Lets call them Home, News, and Contact.  These navigational elements need to animate themselves when told to do so by the main flash animation.

Normally I would bind a method to “setTargetXY”, “doAnimation”, and let the main handler “onEnterFrame” handle the animation from there.

But what about when the movie isn’t moving the navigation around?

I propose the doAnimation should always have a “this.start()”.  Additionally when the animation is over, the main handler should “this.stop();” to stop the moving from entering frames and continuously checking for an “isActive” or other qualifiers to begin animation calculations.

I’ve informally done this before just out of optimizing code, but I think a more formal approach may be beneficial.

Does anyone know if the flash player automatically does this?  Tests for logical qualifiers in movie loops, and stops them until those qualifiers change? 

It could be a nice optimization to the way Flash player handles static objects who have a loop with a single if statement wrapped around.

Related Posts

Tags: , ,

No comments yet.

Leave a comment


Follow Me

Follow seangw on twitter

Email Subscription

Top Commentators

  • No commentators.

Archives

Categories