PDA

View Full Version : Falling Snow - Showing/Hiding the Snow



kirupa
January 14th, 2005, 01:42 PM
Hey everyone,
A question someone asked me earlier was how to make the snow disappear or reappear at a certain point. For example, you may want the snow to fall in Frames 1-30, but beyond that, you would not want any snow to fall. The code I had provided in v2.0 of the tutorial did not address that, so until I write a modified tutorial, I have provided the FLAs (for MX) that help you to control when you want or don't want the snow to fall :beam:

I have provided two variations of the Falling Snow file. One method stops or starts the falling snow by having you press a button (the white/pink circle on the bottom left of the animation). The second method displays the falling snow for about 30 frames, and then it stops displaying the falling snow.

The primary thing you will need to consider in this new version of the falling snow is your placement of:

_root.run = 1 // displays snow- and -

_root.run = 0 // hides snowAlso, I made some minor modifications to the actual Falling Snow code found on the snow movie clip, and that can be found here:

onClipEvent (load) {
//variables
width = 300;
height = 200;
//random x,y, and alpha
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 20+Math.random()*50;
//random x and y for flakes
this._x = -width+Math.random()*(3*width);
this._y = -10+Math.random()*height;
//speed and trigonometric value
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
rad = 0;
this._visible = false;
}
onClipEvent (enterFrame) {
///////////////////
///////////////////
if (_root.run == 1) {
///////////////////
///////////////////
this._visible = true;
// horizontal movement
rad += (k/180)*Math.PI;
xmovement = _root._xmouse;
this._x -= Math.cos(rad)+(xmovement-(width/2))/50;
// vertical movement
this._y += i;
// remove clips when they misbehave (overstep boundaries)
if (this._x>(width+50)) {
this._x = -45;
this._y = Math.random()*height*2;
}
if (this._x<-50) {
this._x = width+45;
this._y = Math.random()*height*2;
}
if (this._y>=height) {
this._y = -50;
this._x = -width+Math.random()*(3*width);
}
///////////////////
///////////////////
} else {
this._visible = false;
}
///////////////////
///////////////////
}
The source files should contain everything I have explained here.

Cheers!
Kirupa :sailor:

xultraloveninja
January 19th, 2005, 04:01 PM
thanks!

that what i was looking for!

worked
October 23rd, 2007, 10:30 AM
Thank you for posting this. Two questions.
1. How can I get the snow to fall at start, then offer the option to stop it and re-start it at will?
2. What if I wanted the button to switch between a stop symbol and start symbol, when applicable?

worked
October 24th, 2007, 01:12 PM
I figured out how to add a separate "on" button and "off" button for the falling snow app, while using swapDepth for the logo: example (http://www.murphydrygoods.com/logo_alt_latest_1.html)

PM me if you wish for the code. :beer:

ZZ_ka
October 25th, 2007, 04:01 AM
Bless You!:?)

minthu
October 25th, 2007, 07:17 AM
That's simply amazing codes! I like this snow effect.

Thanks!

vini
October 25th, 2007, 01:58 PM
Great one Kiru..
Guys check out this one
http://www.platfuse.com

worked
October 30th, 2007, 11:08 AM
Hey Vini- Can you post the .fla for that snow effect? I'm very interested in seeing how that works. If so, thanks in advance!

yarrazulu
June 20th, 2010, 03:32 AM
I cannot download the attachments, pls help

ocal
June 25th, 2010, 03:19 PM
Is there an updated version of this for cs4?

I can't figure out how to make it stop at a certain frame after doing the tutorial. Awesome tutorial by the way.

keymaster
October 27th, 2011, 07:07 PM
This is exactly what I need, except for one issue. I get the fact the angle of the flakes fall according to where the mouse is located but how can I make them always fall straight down. Random angles of say 3-5 degree off straight down would be ideal but straight down would work also. Thank you for any help offered