PDA

View Full Version : Kirupa's snow in ActionScript 2.0


smoothhabitat
12-18-2004, 03:10 AM
This might be a helpful source file for those of you trying to learn AS2. Remember to keep the .as files in the same folder as the .fla, and the files are case-sensitive (so make sure those capital S's are on the .as files!)

It's adapted from Kirupa's tutorial found here (http://www.kirupa.com/developer/mx2004/snow2.htm).

Here are the class files: Snowflake.as (http://www.smoothhabitat.com/blog/as/snow/Snowflake.as) and Snow.as (http://www.smoothhabitat.com/blog/as/snow/Snow.as).

So, download those files and open up a new FLA. Make yourself a little snowflake MovieClip, set the identifier to "*snowflake" (the * is my little method of keeping track of which library objects are pulled in dynamically) and the AS2.0 class to "Snowflake".

Next, on frame 1 (or where ever you want it to start snowing) put in the following line:

var s:Snow=new Snow(100,_root,200,100,1);

The parameters are as follows: number of flakes, the MovieClip you want these flakes to sit in, the width, height, and wind.

For that mouse over effect:

this.onEnterFrame=function() { s.setWind((_xmouse/20)-4); }

Good times.

j_polo9
12-22-2004, 12:42 PM
Don't forget to mention that you can add back in: this._alpha = 20+Math.random()*50; for the alpha effect. Thanks again for the 2.0 update
-Jesse

smoothhabitat
12-22-2004, 01:06 PM
Right! I took that out for speed (I was making it for a game). Thanks Jesse.