# Raining effect?

**URL:** <https://forum.kirupa.com/t/raining-effect/23992>\
**Category:** Uncategorized\
**Created:** [June 25, 2003, 2:46am UTC](https://forum.kirupa.com/t/raining-effect/23992 "2003-06-25T02:46:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viktor](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Viktor](https://forum.kirupa.com/u/Viktor)\
**Post date:** [June 25, 2003, 2:46am UTC](https://forum.kirupa.com/t/raining-effect/23992/1 "2003-06-25T02:46:07Z")

</div>

Hi, I’m doing a flash movie and I would like to know if anybody knows how to simulate rain with Action Script in flash mx.

I tried modifying some snow effect I found in the site, but it didn’t work properly.

Thank You! =)

---

<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:** [June 25, 2003, 3:22am UTC](https://forum.kirupa.com/t/raining-effect/23992/2 "2003-06-25T03:22:04Z")

</div>

I rememeber someone asking for the same effect here so you might want to do a search.

Also here is a file I got a long time ago. It’s not too pretty, but maybe it will give you some ideas.

---

<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:** [June 25, 2003, 3:32am UTC](https://forum.kirupa.com/t/raining-effect/23992/3 "2003-06-25T03:32:49Z")

</div>

[AS]var maxDrops = 50;  
var maxSpeed = 20;  
var minSpeed = 10;  
var movieWidth = 300;  
var movieHeight = 200;  
this.createEmptyMovieClip(“drop”, -1);  
drop.lineStyle(.25, 0x000000, 100);  
drop.moveTo(0, 0) and drop.lineTo(5, -5);  
drop.\_visible = false;  
MovieClip.prototype.rainDown = function() {  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
this.onEnterFrame = function() {  
this.\_x -= this.speed;  
this.\_y += this.speed;  
if (this.\_y\>=movieHeight) {  
this.\_x = Math.random()_(movieWidth+200);  
this.\_y = -5;  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
}  
};  
};  
for (var i = 0; i\<maxDrops; i++) {  
mc = drop.duplicateMovieClip(“drop”+i, i);  
mc.\_x = Math.random()_(movieWidth+200);  
mc.rainDown();  
}[/AS]

Kinda ghetto, but I whipped it up real quick 😛

---

<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:** [June 25, 2003, 3:48am UTC](https://forum.kirupa.com/t/raining-effect/23992/4 "2003-06-25T03:48:48Z")

</div>

looks mighty spiffy to me. 😛

---

<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:** [June 25, 2003, 3:51am UTC](https://forum.kirupa.com/t/raining-effect/23992/5 "2003-06-25T03:51:24Z")

</div>

Thank you!!! It was really useful!!

---

<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:** [June 25, 2003, 4:00am UTC](https://forum.kirupa.com/t/raining-effect/23992/6 "2003-06-25T04:00:46Z")

</div>

Cool :thumb:

Heres a move clean cut version that hides the rain that isn’t on the viewable stage…

[AS]//define variables to use in the movie  
var maxDrops = 50;  
var maxSpeed = 20;  
var minSpeed = 10;  
var movieWidth = 300;  
var movieHeight = 200;  
//create mask the size of your stage  
this.createEmptyMovieClip(“mask”, -1);  
mask.beginFill(0xFF0000, 100);  
mask.moveTo(0, 0);  
mask.lineTo(movieWidth, 0);  
mask.lineTo(movieWidth, movieHeight);  
mask.lineTo(0, movieHeight);  
//create container and drop clip inside  
this.createEmptyMovieClip(“container”, -2);  
container.createEmptyMovieClip(“drop”, -1);  
container.drop.lineStyle(.25, 0x000000, 100);  
container.drop.moveTo(0, 0) and container.drop.lineTo(5, -5);  
container.drop.\_visible = false;  
//set the mask clip to be a mask to the container clips  
container.setMask(mask);  
//function for motion  
MovieClip.prototype.rainDown = function() {  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
this.\_alpha = Math.random()_(100-10)+10;  
this.onEnterFrame = function() {  
this.\_x -= this.speed;  
this.\_y += this.speed;  
if (this.\_y\>=movieHeight) {  
this.\_x = Math.random()_(movieWidth+200);  
this.\_y = -5;  
this.\_alpha = Math.random()_(100-10)+10;  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
}  
};  
};  
//create rain clips inside the container clip  
for (var i = 0; i\<maxDrops; i++) {  
mc = container.drop.duplicateMovieClip(“drop”+i, i);  
mc.\_x = Math.random()_(movieWidth+200);  
mc.rainDown();  
}[/AS]

[edit]I added a little more depth by adding a random alpha property[/edit]

---

<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:** [June 25, 2003, 4:06am UTC](https://forum.kirupa.com/t/raining-effect/23992/7 "2003-06-25T04:06:57Z")

</div>

Slightly more vertical…

[AS]//define variables to use in the movie  
var maxDrops = 50;  
var maxSpeed = 20;  
var minSpeed = 10;  
var movieWidth = 300;  
var movieHeight = 200;  
//create mask the size of your stage  
this.createEmptyMovieClip(“mask”, -1);  
mask.beginFill(0xFF0000, 100);  
mask.moveTo(0, 0);  
mask.lineTo(movieWidth, 0);  
mask.lineTo(movieWidth, movieHeight);  
mask.lineTo(0, movieHeight);  
//create container and drop clip inside  
this.createEmptyMovieClip(“container”, -2);  
container.createEmptyMovieClip(“drop”, -1);  
container.drop.lineStyle(.25, 0x000000, 100);  
container.drop.moveTo(0, 0) and container.drop.lineTo(2, -7);  
container.drop.\_visible = false;  
//set the mask clip to be a mask to the container clips  
container.setMask(mask);  
//function for motion  
MovieClip.prototype.rainDown = function() {  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
this.\_alpha = Math.random()_(100-10)+10;  
this.onEnterFrame = function() {  
this.\_x -= this.speed/2;  
this.\_y += this.speed;  
if (this.\_y\>=movieHeight) {  
this.\_x = Math.random()_(movieWidth+200);  
this.\_y = -5;  
this.\_alpha = Math.random()_(100-10)+10;  
this.speed = Math.random()_(maxSpeed-minSpeed)+minSpeed;  
}  
};  
};  
//create rain clips inside the container clip  
for (var i = 0; i\<maxDrops; i++) {  
mc = container.drop.duplicateMovieClip(“drop”+i, i);  
mc.\_x = Math.random()_(movieWidth+200);  
mc.rainDown();  
}[/AS]

Can anyone tell I am bored?

---

<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:** [June 25, 2003, 4:13am UTC](https://forum.kirupa.com/t/raining-effect/23992/8 "2003-06-25T04:13:01Z")

</div>

That’s superb!! - not sure quite how bored you are, but, if you increased the number of drops and varied their alpha levels randomly, sped it up, and faded the impact circles out the further away they were, and made it all greyer… it’d look like London.

---

<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:** [June 25, 2003, 4:18am UTC](https://forum.kirupa.com/t/raining-effect/23992/9 "2003-06-25T04:18:33Z")

</div>

Actually if I did all that it would look like someones computer would blow up from the CPU Usage 😛

---

<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:** [June 25, 2003, 4:38am UTC](https://forum.kirupa.com/t/raining-effect/23992/10 "2003-06-25T04:38:23Z")

</div>

Ok - so perhaps more like New York…:beam:
