g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Home Improvement
Women's Fashion
Small Office/Home Office
Holiday/Seasonal Cooking
Crafts for Kids

All times in EST

Full Schedule
g Flash and Animation Site

BellaOnline's Flash and Animation Editor


ActionScript 3 Particle System Snowfall Animation in Flash

Method Two

The second method will allow us to use only a few snowflakes instead of continuously creating new ones. But to do this, we will need to find a way to recycle the snowflakes that we do create. The first step is to change the way we call the snowflake function which creates the snowflakes. We no longer want to create a new snowflake with each new frame, so we will need to remove the Event Listener at the top of the code.

stage.addEventListener(Event.ENTER_FRAME, snowflake);

Now we will add the code that will create a small number of snowflakes. We will use a for loop statement within the snowflake function to control the number of snowflakes that will be created. We will need about 70 snowflakes. If we increase this number much higher, the animation will again become tasking. Place your cursor inside the snowflake function code, just after the opening curly bracket and add the line of code which will tell Flash to repeat the snowflake function 70 times. Next, add the opening curly bracket for the loop. You might recognize this for loop code from the second tutorial in this series.

function snowflake(event:Event):void
for (var i:Number = 0; i < 70; i++)

The rest of the snowflake function code should remain the same. Now, we need to close the for loop with a closing curly bracket. Place this bracket just after last line of the function. Here is the code. I have moved the body of the function to the right to make it more readable. However, this is not necessary for the code to work.

Finally, we need to remove the snowfall function from within the snowflake function. This is easy to do. Just move the curly bracket that closes the snowflake function from the bottom of the program to just under the end of the for loop code. Now we have two functions that are completely separate from each other.

Because we are no longer calling the snowflake function with the Event Listener that we removed from the top of the code, we will need to call it with a simple function call instead. Since we are using a for loop statement within the function to repeat the function 70 times, we only need to call the function itself once. At the end of the entire program code, place this function call.


Finally, we need to remove the removeChild code that we added to our code for Method One. Remember that we want to recycle these snowflakes instead of removing them from the display list. Remove the following code.


If you test your movie, you will get error messages. Let's take care of the last error in the list. We got this error message because we have one argument inside the parentheses of the snowflake function code. But we are no longer using this "event:Event" argument since we removed the Event Listener. We need to remove the "event:Event" from inside the parentheses.

function snowflake():void

← Back | Next →

Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Twitter Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Facebook Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to MySpace Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Del.icio.us Digg ActionScript+3+Particle+System+Snowfall+Animation+in+Flash Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Yahoo My Web Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Google Bookmarks Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash to Stumbleupon Add ActionScript+3+Particle+System+Snowfall+Animation+in+Flash 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

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2015 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 features
Animation Software Terms

Why Hype 3.5 and Pro

Tumult Hype and Pro Intro

Archives | Site Map


Past Issues

Less than Monthly

BellaOnline on Facebook

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

BellaOnline Editor