Tuesday, March 17, 2009

Create falling snow on flash

This tutorial help you to create a falling snow effect in Flash.

Lets start.

1. Create a new document with size 500x500. The frame rate must be 20 or 25 for smooth animation. For this tutorial I choose 25. The color of background must be black (or some other, but dark color).




2. Now you have to create a new symbol. There is 2 ways for that - press F8 or go to Insert->New Symbol




* Remember, that in the Type menu must be selected "Movie Clip"

3. Now you must to draw one single snowflake. In the symbol you created, create the snowflake the way you like. For this tutorial I choose circle with gradient.




4. Press on the Scene 1 button to go to the main scene




5. Now go to Window->Library or press Ctrl + L. Find your movie clip you just created and click on it with the right mouse button. Choose Linkage and be sure that the Linkage properties of the movie clip are as the image bellow:




Ok - you will say - We create just a single snowflake, but we whant a snowfall. Do not worry - here will help us the Actionscript code.

6. Click on Frame 1 in the timeline




7. Press F9 or go to Window->Actions.

8. Copy the code bellow and paste it to the just opened window called Actions

width = 500;
height = 500;
total = 200;
for (var t = 0; t != total; t++) {
var mc = _root.attachMovie("snowflake", "snowflake"+t, _root.getNextHighestDepth());
mc._x = (Math.random()*(width+20))-10;
mc._y = (Math.random()*(height+20))-10;
mc.yspeed = (Math.random()*1.75)+0.25;
mc.speed = (Math.random()*3)+2;
mc._xscale = mc._yscale=(mc.speed+mc.yspeed)*10;
mc.onEnterFrame = function() {
var angle = Math.atan2(_root._xmouse-(width/2), _root._ymouse)+1.5707963267949;
this._y += Math.sin(angle)*this.speed+this.yspeed;
this._x += Math.cos(angle)*this.speed;
if (this._x>width+10) {
this._x = -10;
} else if (this._x<0-10) {
this._x = width+10;
}
if (this._y>height+10) {
this._y = -10;
} else if (this._y<0-10) {
this._y = height+10;
}
};
}


9. Now press Ctrl + Enter to see your creation

You can play with the actionscript to change the number of flakes, the speed etc. Be carefull with corrections

Keep Flashing :)

Bookmark and Share


1 Comments:

Anonymous Anonymous said...

Very nice tutor. Explain, pls, more how to edit the script to change the parameter. 10x

March 17, 2009 at 10:09 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home