# Random Colours in Falling Snow

**URL:** <https://forum.kirupa.com/t/random-colours-in-falling-snow/29568>\
**Category:** flash\
**Created:** [August 28, 2003, 7:44am UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568 "2003-08-28T07:44:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timage](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@Timage](https://forum.kirupa.com/u/Timage)\
**Post date:** [August 28, 2003, 7:44am UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568/1 "2003-08-28T07:44:06Z")

</div>

G’day.

How would I go about making the snow flakes in the Falling Snow tutorial random colours? I read the random colour generator tutorial but I don’t know how to make it happen autiomatically.

What would I add to the script to do this?

---

<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:** [August 28, 2003, 12:50pm UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568/2 "2003-08-28T12:50:21Z")

</div>

Change this line [AS]for (k=0; k\<50; k++) {  
duplicateMovieClip(\_root.snow, “snow”+k, k);  
}[/AS] to this [AS]for (k=0; k\<50; k++) {  
mc = duplicateMovieClip(\_root.snow, “snow”+k, k);  
c = new Color(mc);  
c.setRGB(Math.round(Math.random()\*0xFFFFFF));  
}[/AS]

That sets an ID (“mc”) to the duplicated clip, uses the Color() object to target the newly duplicated clip, and then sets the RGB color of that clip to a random color (the code was taking from another random color tutorial at [kirupa.com](http://kirupa.com), I believe in the AS Tricks section)

---

<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:** [August 28, 2003, 1:15pm UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568/3 "2003-08-28T13:15:06Z")

</div>

Or add this to your snow clip:[AS]onClipEvent (load) {  
myColor = new Color(this);  
myColorTransform = new Object();  
myColorTransform.ra = (Math.random()\<.5) ? Math.random()_100 : -1_Math.random()\*100;  
myColorTransform.rb = (Math.random()\<.5) ? Math.random()_255 : -1_Math.random()\*255;  
myColorTransform.ga = (Math.random()\<.5) ? Math.random()_100 : -1_Math.random()\*100;  
myColorTransform.gb = (Math.random()\<.5) ? Math.random()_255 : -1_Math.random()\*255;  
myColorTransform.ba = (Math.random()\<.5) ? Math.random()_100 : -1_Math.random()\*100;  
myColorTransform.bb = (Math.random()\<.5) ? Math.random()_255 : -1_Math.random()\*255;  
myColorTransform.aa = (Math.random()\<.5) ? Math.random()_100 : -1_Math.random()\*100;  
myColorTransform.ab = (Math.random()\<.5) ? Math.random()_255 : -1_Math.random()\*255;  
myColor.setTransform(myColorTransform);  
}[/AS]

---

<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:** [August 28, 2003, 10:02pm UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568/4 "2003-08-28T22:02:17Z")

</div>

Thankyou very much guys!

---

<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:** [August 29, 2003, 1:41pm UTC](https://forum.kirupa.com/t/random-colours-in-falling-snow/29568/5 "2003-08-29T13:41:26Z")

</div>

welcome :thumb:
