# Help with Random Motion/Color Tutorial

**URL:** <https://forum.kirupa.com/t/help-with-random-motion-color-tutorial/169729>\
**Category:** flash\
**Created:** [November 18, 2005, 8:06pm UTC](https://forum.kirupa.com/t/help-with-random-motion-color-tutorial/169729 "2005-11-18T20:06:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjhughes](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@fjhughes](https://forum.kirupa.com/u/fjhughes)\
**Post date:** [November 18, 2005, 8:06pm UTC](https://forum.kirupa.com/t/help-with-random-motion-color-tutorial/169729/1 "2005-11-18T20:06:30Z")

</div>

Hello,

I tweaked the Random Motion tutorial and added in a random scale and alpha to make random polka dots moving on the screen. It looked great with the white background, but I need it on black. A low alpha on a pink polka dot with a black background… well, it’s not really pink. 😉 I found a tutorial that would cycle through random numbers to generate random hex numbers for color. But I need to randomly cycle through these specific colors: [size=2][color=navy][font=Arial][font=Verdana][color=black]#FFB6C1,[/color][/font][/font][/color][/size][size=2][color=navy][font=Arial][font=Verdana][color=black] #FFCOCB, [/color][/font][/font][/color][/size][size=2][color=navy][font=Arial][font=Verdana][color=black]#FFFOF5, [/color][/font][/font][/color][/size][size=2][color=navy][font=Arial][font=Verdana][color=black]#FF69B4.[/color][/font][/font][/color][/size]  
[size=2][color=navy][font=Arial][font=Verdana][color=black][/color][/font][/font][/color][/size]  
[size=2][color=navy][font=Arial][font=Verdana][color=black]Can anyone offer any suggestions.[/color][/font][/font][/color][/size]  
[font=Verdana][size=2][color=#000000][color=navy][font=Arial][/font][/color][/color][/size][/font]  
[font=Verdana][size=2][color=#000000][color=navy][font=Arial]Here is the code on the “dot” MovieClip:[/font][/color][/color][/size][/font]  
[color=navy][font=Arial]

```auto
 
[color=navy][font=Arial][/font][/color]onClipEvent (load) {
	 //data you may want to change
	 width = 760;
	 height = 600;
	 speed = Math.round(Math.random()*2)+1;
	 scale = (random(100) + 50)
	 this._alpha = random(100);
	 this._xscale = scale;
	 this._yscale = scale;
 
	 //initial positions
	 x = Math.random()*width;
	 y = Math.random()*height;
	 this._x = x;
	 this._y = y;
	 x_new = Math.random()*width;
	 y_new = Math.random()*height;
}
onClipEvent (enterFrame) {
	 //x movement
	 if (x_new>this._x) {
		 sign_x = 1;
	 } else {
		 sign_x = -1;
	 }
	 dx = Math.abs(x_new-this._x);
	 if ((dx>speed) || (dx<-speed)) {
		 this._x += sign_x*speed;
	 } else {
		 x_new = Math.random()*width;
	 }
	 //y movement
	 if (y_new>this._y) {
		 sign_y = 1;
	 } else {
		 sign_y = -1;
	 }
	 dy = Math.abs(y_new-this._y);
	 if ((dy>speed) || (dy<-speed)) {
		 this._y += sign_y*speed;
	 } else {
		 y_new = Math.random()*height;
	 }
}
 

```

[/font][/color]
