# Falling snow modification

**URL:** <https://forum.kirupa.com/t/falling-snow-modification/15909>\
**Category:** flash\
**Created:** [March 19, 2003, 8:27am UTC](https://forum.kirupa.com/t/falling-snow-modification/15909 "2003-03-19T08:27:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom76](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@tom76](https://forum.kirupa.com/u/tom76)\
**Post date:** [March 19, 2003, 8:27am UTC](https://forum.kirupa.com/t/falling-snow-modification/15909/1 "2003-03-19T08:27:05Z")

</div>

I’m using Flash MX and am following the falling snow tutorial in the actionscript section. What I’d like is for the snow to move from right to left, but still with the random y position.

This code gives me snow (particle) moving right, left, and right again but most ends up along the top (y value of 0).

Any thoughts?

onClipEvent (load) {  
//specifies the size of the movie stage  
movieWidth = 131;  
movieHeight = 100;

```
//variables that will modify the moving particle
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;

//giving each particle unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;

```

}  
onClipEvent (enterFrame) {  
//putting it all together  
rad += (k/180)\*Math.PI;  
this.\_x -= Math.cos(rad);  
// this.\_y += i;  
if (this.\_y\>=movieHeight) {  
this.\_y = -5;  
}  
if ((this.\_x\>=movieWidth) || (this.\_x\<=0)) {  
this.\_x = -10+Math.random()\*movieWidth;  
this.\_y = -5;  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 19, 2003, 10:53am UTC](https://forum.kirupa.com/t/falling-snow-modification/15909/2 "2003-03-19T10:53:40Z")

</div>

I’ve played around and got the following, but still it is not quite right.

onClipEvent (load) {  
//specifies the size of the movie stage  
movieWidth = 131;  
movieHeight = 100;

```
//variables that will modify the moving particle
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;

//giving each particle unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;

```

}  
onClipEvent (enterFrame) {  
//putting it all together  
rad += (k/180)\*Math.PI;  
this.\_x -= Math.cos(rad);  
// this.\_y += i;  
if (this.\_y\>=movieHeight) {  
delete this;  
}  
if ((this.\_x\>=movieWidth) || (this.\_x\<=0)) {  
this.\_x = -10+Math.random()\*movieWidth;  
this.\_y = -10+Math.random()\*movieHeight;  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 19, 2003, 11:14am UTC](https://forum.kirupa.com/t/falling-snow-modification/15909/3 "2003-03-19T11:14:15Z")

</div>

No matter, found a good effect. I changed this line

this.\_x -= Math.cos(rad);

to be an integer constant. Works a treat.
