Tutorio.com

Pages: 1.2.
Flash Snow
Just a nice looking flash snow effect.

Introduction

A tutorial on creating snow is not very original, but its a good place to start moving beyond basic actionscript and the same principles can be applied to lots of other situations. The source fla can be downloaded by clicking here

There are many ways to go about creating snowfall effects in flash before writing any actionscript heres a basic introduction to how this particular snow effect will work.

  1. A set number of snowflakes are generated.
  2. The generated snow flakes fall.
  3. If the snowflake moves out of the screen area it is reset to the top of the screen.

Setup

The setup for this movie is simple draw out a snowflake and convert it to a movieclip. Then set its linkage to export for actionscript and its identifier to "flake".

Note: You can set the linkage for the movie by right clicking on the movieclip and then from the context menu choose Linkage... to open up the linkage properties for the symbol.

Snowflake Generation

amount = 100;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; i<amount; i++) {
thisFlake = this.attachMovie("flake", "flake"+i, i);
with (thisFlake) {
_x = Math.random()*mWidth;
_y = Math.random()*mHeight;
_xscale = _yscale=_alpha=40+Math.random()*60;
}
}

First some initial variables are set up such as the number of snowflakes to be generated, and the height and width of the movie

A snow flake is attached using the attachMovie and given the variable thisFlake is assigned as a temporary refrence.

The snow flake is then positioned randomly and the width, height and transparancy are also set randomly.

Note: The expression 40+Math.random()*60, generates a radom number between 40 and 100. Math.radom() generates random numbers between 0 and 1, this is multiplied by 60 to get a random number between 0 and 60 and then 40 is added to get a random number between 40 and 100. This way the snowflakes will have atleast partial visibility.

Next Page >>

Rating(124) +- Pages: 1.2.
Tutorio.com. Privacy Policy, Contact