Toxiclab.org

Falling Snow animation in flash

17.12.2008, 18:24
Submited in: Flash | Total Views: 46295

See this simple and quickly flash 8 action script lesson and learn how to create falling snow animation in flash.  You can use this animation for any holidays header, banner, Christmas card... Using this lesson, you will also learn how to convert any object into a Movie Clip Symbol, how to apply action script code on it using the action script panel and much more!



Step 1

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Choose some kind of a dark color as background color. Set your Flash movie's frame rate to 27 and click ok.





Step 2


Take now the Oval Tool (O). In the Colors portion of the Tool panel, block the Stroke color by clicking on the little pencil icon and then on the small square with the red diagonal line. For Fill color choose white color and draw a "circle" about 4x4 px.



Step 3

While the circle is still selected, press F8 key (Convert to Symbol) to convert this circle into a Movie Clip Symbol.



Step 4

While the new made Movie Clip (circle) is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip "snow". See the picture below!



Step 5

Select the Selection Tool (V) and click once on the Movie Clip (circle) to select it. Then, go to the Action Script Panel (F9) and enter this code inside the actions panel:

onClipEvent (load) {
 movieWidth = 350;
 movieHeight = 263;
 
 i = 1+Math.random()*2;
 k = -Math.PI+Math.random()*Math.PI;
 
 this._xscale = this._yscale=50+Math.random()*100;
 this._alpha = 75+Math.random()*100;
 this._x = -10+Math.random()*movieWidth;
 this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
 rad += (k/180)*Math.PI;
 this._x -= Math.cos(rad);
 this._y += i;
 if (this._y>=movieHeight) {
  this._y = -5;
 }
 if ((this._x>=movieWidth) || (this._x<=0)) {
  this._x = -10+Math.random()*movieWidth;
  this._y = -5;
 }
}

Step 6

Select now the first frame, go again to the Action Script Panel (F9) and enter this code inside the actions panel:

for (k=0; k<50; k++) {
 duplicateMovieClip(this.snow, "snow"+k, k);
}

Now, we're done!

Test your Movie and enjoy!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials