logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Full Schedule
g
g Flash and Animation Site

BellaOnline's Flash and Animation Editor

g

Optimizing Flash CS3 Particle System Animation


Now that we have the FlashR CS3 particle system snowfall animation working exactly like we want, it's time to optimize the snow scene program code. If you tested the animation that we have written in the previous tutorials, you probably noticed that after a time, the animation tends to task your computer's resources. In this tutorial, we will look at a few ways to make the animation more efficient.

As the code stands now, we are using one Event Listener to listen for each new frame of the animation. With each new frame, the snowflake function (event handler) creates a new snowflake and adds that snowflake to the Flash display list. Next, we use Math.random() to randomize the position and alpha properties of this snowflake. We use a second Event Listener to call the snowfall function, again with each new frame. The snowfall function checks to see if the snowflake has moved beyond the right or bottom edge of the stage. If so, we remove the second Event Listener that repeats the snowfall function. This causes that one snowflake to stop falling, while the other snowflakes continue to fall. The repetition of the snowflake function creates the snowfall animation. What we need to do now is to change the code so that it is more efficient.

Method One

The first method requires the addition of only one line of code to our program. We already have a conditional statement inside the snowfall function that checks to see if the snowflake has gone beyond the stage and, if so, removes the Event Listener and stops the snowflake from falling.
The snowflake stops moving but it is still visible at the bottom of the stage. Because it is still visible and still on the display list, Flash still spends resources on this snowflake. If we remove the snowflake from the display list, it will free up the resources and the animation will be more efficient. To remove the snowflakes that we no longer need on the display list, we can add a removeChild code to the conditional statement.

if ( _Snowflake.y> 370 || _Snowflake.x> 550)
{
stage.removeEventListener(Event.ENTER_FRAME, snowfall);
removeChild(_Snowflake);
}
else
{ _Snowflake.y += 5; _Snowflake.x += Math.random() * 10; }

When you test your movie, the snowflakes disappear as they reach the right or bottom edge of the stage and the animation is more efficient.

Next →




Add Optimizing+Flash+CS3+Particle+System+Animation to Twitter Add Optimizing+Flash+CS3+Particle+System+Animation to Facebook Add Optimizing+Flash+CS3+Particle+System+Animation to MySpace Add Optimizing+Flash+CS3+Particle+System+Animation to Del.icio.us Digg Optimizing+Flash+CS3+Particle+System+Animation Add Optimizing+Flash+CS3+Particle+System+Animation to Yahoo My Web Add Optimizing+Flash+CS3+Particle+System+Animation to Google Bookmarks Add Optimizing+Flash+CS3+Particle+System+Animation to Stumbleupon Add Optimizing+Flash+CS3+Particle+System+Animation to Reddit



 



RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the Flash and Animation Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.

g


g features
Motion 5 Parallax Effect - The Graphics

Animate Lower Third in Motion 5

Drop Zone and Lower Third in Motion 5

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor