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

Holiday/Seasonal Cooking
Crafts for Kids
Computer Careers
Mexican Food
Autism Spectrum Disorders

All times in EST

Full Schedule
g Flash and Animation Site

BellaOnline's Flash and Animation Editor


Flash CS3 ActionScript 3 Particle System

The other error messages happened because we removed the snowfall function from within the snowflake function. Because of this, the snowfall function does not know how to recognize the snowflakes. We need to make a change to the snowfall function code to tell it to recognize the current snowflake that has just been created. We will change "_Snowflake" to "event.target" in the four places that it occurs.

We have one more correction before we can test our movie again. Let's go back to the snowflake function code. The Event Listener inside this code calls the snowfall function. But it is still listening to the stage. We need to change this so that the Event Listener is attached to each new snowflake as it is created, and not to each new frame of the animation. At the front of the Event Listener code, change "stage" to "_Snowflake".

Test again. No errors and we have all 70 snowflakes falling to the bottom of the stage. But then the animation stops because we are not creating any new snowflakes after the initial 70 snowflakes. We need to add some code that will recycle these 70 snowflakes back up to the top of the stage. As we move these snowflakes back to the top, let's use the same Math.random() code that we used in the snowflake function to randomly place our recycled snowflakes. But this time we need to use the "event.target" instead of "_Snowflake".

Finally, we need to remove the removeEventListener code from inside the snowfall function. We do not want to stop our snowflakes from falling anymore. We want them to go to the top and fall down again. Here is the new code for the conditional statement.

Test again and you will see 70 snowflakes fall from the top to the stage followed by the recycled snowflakes. But there are a few seconds before the recycled snowflakes begin to fall. It would be a much smoother animation if we could change the code so that the initial 70 snowflakes are place over the entire stage instead of just at the top. Let's go back to the snowflake function and change the "40" to "400" for the_Snowflake.y property. This will place the 70 initial snowflakes at random positions from 0 to 400 along the Y axis which will cover the entire stage.

Test again and we have success. Save your snow scene as SnowScene10.fla.

Now we have our animation optimized and animating perfectly, we could stop here. But with just a few changes, we could make this code a more modular particle system. Then we could use the code to make anything from rain to pigs fall from the sky. We will do that next.

← Back

Add Flash+CS3+ActionScript+3+Particle+System to Twitter Add Flash+CS3+ActionScript+3+Particle+System to Facebook Add Flash+CS3+ActionScript+3+Particle+System to MySpace Add Flash+CS3+ActionScript+3+Particle+System to Del.icio.us Digg Flash+CS3+ActionScript+3+Particle+System Add Flash+CS3+ActionScript+3+Particle+System to Yahoo My Web Add Flash+CS3+ActionScript+3+Particle+System to Google Bookmarks Add Flash+CS3+ActionScript+3+Particle+System to Stumbleupon Add Flash+CS3+ActionScript+3+Particle+System 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
Snow Flurry Emitter in Apple Motion

Background Clips in Apple Motion Project

VideoHive Project Requirements

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