Falling Snow Tutorial - Reverse Snowfall?

Hey All,

How would I reverse the Snowfall direction in the “Falling Snow” tutorial found at http://www.kirupa.com/developer/mx/snow.htm

And also, how could I limit the spawn point to a certain location. In other words, how can I make all the snowflakes start at the same place.

This is probably easy, but I am learning Actionscript as I go along…:thumb:

thanks

mecha

there are many threads going over exactly this :wink:

take some time on the search button up there (between online and home) and search on things like “snow” and “bubbles” (which is what everyone wants from upside-down snow) and you’ll find a lot!

:beam:

Make it like this:

onClipEvent (load) {
	//specifies the size of the movie stage
	movieWidth = 300;
	movieHeight = 200;
	
	//variables that will modify the falling snow
	i = 1+Math.random()*2;
	k = -Math.PI+Math.random()*Math.PI;
	
	//giving each snowflake unique characteristics
	this._xscale = this._yscale=50+Math.random()*100;
	this._alpha = 75+Math.random()*100;
/*->*/	this._x = /// where you want it to spawn
/*->*/	this._y = /// where you want it to spawn
}
onClipEvent (enterFrame) {
	//putting it all together
	rad += (k/180)*Math.PI;
	this._x -= Math.cos(rad);
	this._y += i;
/*->*/	// changed to "<" and "+5"
	if (this._y<=movieHeight) {
		this._y = +5;
	}
/*->*/	// changed to "+5"
	if ((this._x>=movieWidth) || (this._x<=0)) {
		this._x = -10+Math.random()*movieWidth;
		this._y = +5;
	}
}

I may have made some mistakes in there, but basically you just want to change the “random spawning point” (which should be easy for you to see) and the y movement to positive instead of negative.

Why do you want snow moving up?

Hey, yeah, what sen said :wink:

just fyi, the easiest is to put it in a movieclip and turn the movieclip upside-down. Theres a post out there on how to do that :wink: - I know I still have the swf laying around out there uploaded
http://userpages.umbc.edu/~tmccau1/flash/snowtobubbles.swf

the only problem might be you may need to change any _root’s to this’s (this SHOULD work, though maybe not - basically its keeping all values and methods in THAT movieclip, and not _root since the movieclip is whats going to be turned upsidedown :wink:

Hey,

Thanks for the replies:

jingman - I need snow going up so I can create a kind of Final Fantasy style twinkle / fairy kind of effect behind a logo for a website I am working on. Imaging the snowflakes replaced by white to transparent circles floating up from behind a 3D company logo. Thats the idea anyway!

I will try the code you supplied, thanks again!

senocular - Thanks for the upside down movieclip solution. I tried that but it didnt want to work. I will try it again but thoroughly checking the script for “_root”!

Thanks again guys!

If I make any progress I will let ya know.

mecha

Hey guys,

figured it out and it works great. Here is the revised code:

onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 300;
movieHeight = 200;
//variables that will modify the falling snow
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
//EDIT 1 - THIS IS WHERE I SAY WHERE TO SPAWN
this._x = 100;
this._y = 100;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
//EDIT 3 - CHANGING “this._y += i;” to “this._y -= i;” reverses the direction
this._y -= i;
if (this._y<=-this._height) {
//EDIT 4 - RECONFIGURE THIS SPAWN POINT
this._y = 100;
this._x = 100;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
//EDIT 5 - RECONFIGURE THIS SPAWN POINT
this._x = -5;
this._y = -5;
}
}

Basicaly, after reversing the snowfall direction the only thing left to do was eliminate the random respawn points which is done in EDITS 4 & 5.

Thanks for your help guys!

mecha

tried changing the value’s on the spawn points but the mc just freezes if i do :S