Her

Home Flash & Swish Flash Tutorials Create Snowfall Effect

Create Snowfall Effect

Author: Selteco.com Author's URL: www.flashdesignerzone.com More by this author

This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

Download source project t1053.zip (2 kb)

  1. Launch Flash Designer and set movie dimensions 400 x 300 (or any desired).
  2. Change frame delay to "Stop".
  3. Add new frame, change "Frame 1" to "Master Frame (1)"
  4. Go to "Frame 1", select "Master Frame (1)" as the background:
Create a snowflake
  1. Go to "Frame 1"
  2. Draw ellipse about 16x16 pixels, set line width to none
  3. Fill it with radial gradient (center color white, outer color "No Color")
  4. Convert it to sprite ("Edit" > "Convert to Sprite")
  5. Rename it to "Snowflake" and check "ActionScript Target" under "Item" > "Placement Properties"
  6. Move the snowflake sprite outside visible area
Create a background
  1. Go to "Master Frame (1)"
  2. Draw a rectangle 400 x 300 and set line width to none
  3. Fill it with vertical gradient, top color dark blue, bottom color light blue
  4. Center the rectangle on the master frame
Add ActionScript:

Go to "Frame 1", choose "Frame" > "ActionScript" and paste the code:

maxsnowflakes = 100;
var snowflakes = new Array();
for(i=0;i<maxsnowflakes;i++)
{
snowflakes[i] = Snowflake.duplicateMovieClip ("snowflake"+i,100+i);
// put it in random place
snowflakes[i]._x = Stage.width*Math.random();
snowflakes[i]._y = Stage.height*Math.random();
snowflakes[i]._xscale = 40+Math.random()*60;
snowflakes[i]._yscale = snowflakes[i]._xscale;
snowflakes[i].yspeed = Math.random()*4+ 1;
snowflakes[i].increment = -0.025+Math.random()*0.05;
snowflakes[i].onEnterFrame = function() {
this.radians = this.increment + this.radians;
this._y = this.yspeed + this._y;
this._x = Math.sin(this.radians) + this._x;
if (this._y>Stage.height) {
this._y = 0-10;
this._x = 0-10+Math.random()*Stage.width;
}
}
}

Hit F9 for preview.

INFO: to place an object in front of snowflakes, select it, choose "Item" > "Placement Properties" and change the layer to higher value, for example "Layer 3":

Create Snowfall Effect