Flash Optimizations of onClip enterFrame events
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.
No comments yet.
Leave a comment
Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info
