Selteco.com > FlashDesignerZONE.com > Tutorials > T1053

Create snowfall effect.

Download source project t1053.zip (2 kb)

  1. Launch Flash Designer and choose Blank document
  2. Choose Frame > Frame size and set movie dimensions 500 x 500 (or any desired).
  3. Choose Frame > Frame delay and set "Stop at this frame".
  4. Choose Frame > Insert to add a new frame
  5. Go back to Frame 1 and choose Frame > Master to change "Frame 1" as "Master Frame (1)"
  6. Go to second frame now called "Frame 1", choose Frame > Frame delay and select "Master Frame (1)" as the background

Create a snowflake
  1. Go to "Frame 1"
  2. Choose Insert > Shape or Line > Glow
  3. Choose Item > Resize and enter 16 x 16 pixels
  4. Convert it to sprite ("Edit" > "Convert to Sprite")
  5. Press F2 and enter Iten Name: "Snowflake" and check "ActionScript Target"
  6. Move the snowflake sprite outside visible area
Create a background
  1. Go to "Master Frame (1)"
  2. Choose Insert > Shape or Line > Background Rectangle
  3. Choose Item > Gradient Fill and change colors to blue
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].radians = 0; 

	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.

See also: T1059 Hearts

Products | Purchase | Downloads | Support | Flash Tutorials | Contact
Copyright © 1999-2017 Selteco Software, Inc. www.selteco.com, ph: +1 810 377 5778