Hi, I found the flash tutorial on generating snow using action script and wanted to use it for a project I’m doing, but instead of having it move downwards, I wanted to have the snow, or in my case bubbles, move upwards instead. I figured out how to make them move up, but once they leave the frame, they reappear at the top of the window instead of at the bottom. Here’s the script.
init = function () {
width = 750;
// pixels
height = 520;
// pixels
max_snowsize = 7;
// pixels
snowflakes = 20;
// quantity
for (i=0; i<snowflakes; i++) {
t = attachMovie("Bubble", "Bubble"+i, i);
t._alpha = 20+Math.random()*60;
t._x = -(width/2)+Math.random()*(1.5*width);
t._y = -(height/2)+Math.random()*(1.5*height); <---------*this is the line I can't figure out. I think this determines the starting y position for all new bubbles. This is what happens in mine. It starts fine and the bubbles spawn randomly and move upwards. But when the bubbles move offscreen, they respawn at the top of the scene. I'm trying to figure out how to make them respawn at the bottom so they can continue moving up.*
t._xscale = t._yscale = 50+Math.random()*(max_snowsize*10);
t.k = 1+Math.random()*2;
t.wind = -1.5+Math.random()*(1.4*3);
t.onEnterFrame = mover;
}
};
mover = function() {
this._y += this.k; <----------*I changed this to -= so they travel* *upwards instead.*
this._x += this.wind;
if (this._y>height+10) {
this._y = -20;
}
if (this._x>width+20) {
this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;
} else if (this._x<-20) {
this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;
}
}
init();
Can anyone help?