# Problem getting a random gradient fill to work

**URL:** <https://forum.kirupa.com/t/problem-getting-a-random-gradient-fill-to-work/93991>\
**Category:** Uncategorized\
**Created:** [November 7, 2003, 2:26am UTC](https://forum.kirupa.com/t/problem-getting-a-random-gradient-fill-to-work/93991 "2003-11-07T02:26:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CandyMann\_69](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@CandyMann\_69](https://forum.kirupa.com/u/CandyMann_69)\
**Post date:** [November 7, 2003, 2:26am UTC](https://forum.kirupa.com/t/problem-getting-a-random-gradient-fill-to-work/93991/1 "2003-11-07T02:26:23Z")

</div>

Any ideas?

This works with having normal gradient fill with color:  
[AS]  
color\_red = 0xFF0000;  
color\_blue = 0x0000FF;  
\_root.gear\_x\_width = Math.floor(Math.random()_60)+10;  
\_root.gear\_y\_width = Math.floor(Math.random()20+\_root.gear\_x\_width;  
\_root.gear\_num\_spokes = Math.floor(Math.random()5)+6;  
\_root.gear\_inside = Math.floor(Math.random()\_root.gear\_x\_width/8)+\_root.gear\_x\_width/6;  
\_root.gear\_outside = Math.floor(Math.random()\_root.gear\_x\_width/10)+\_root.gear\_x\_width/10;  
//  
with (\_root[“gear”+1+i]) {  
lineStyle(1, color\_red, 100);  
colors = [color\_blue, color\_red];  
alphas = [100, 100];  
ratios = [0, 255];  
matrix = {a:0, b:\_root.gear\_y\_width_1.5, c:0, d:\_root.gear\_x\_width\*1.5, e:0, f:0, g:0, h:0, i:1};  
beginGradientFill(“radial”, colors, alphas, ratios, matrix);  
draw\_gear(0, 0, gear\_x\_width, gear\_y\_width, gear\_num\_spokes, gear\_inside, gear\_outside);  
endFill();  
}  
[/AS]

This code just gives me black inside, but the fill color on the outside line is random.

```auto

_root.gear_x_width = Math.floor(Math.random()*60)+10;
_root.gear_y_width = Math.floor(Math.random()*20)+_root.gear_x_width;
_root.gear_num_spokes = Math.floor(Math.random()*5)+6;
_root.gear_inside = Math.floor(Math.random()*_root.gear_x_width/8)+_root.gear_x_width/6;
_root.gear_outside = Math.floor(Math.random()*_root.gear_x_width/10)+_root.gear_x_width/10;
//
with (_root["gear"+1+i]) {
	fill_color_a = "0x"+(Math.floor(Math.random()*255)+1).toString(16) +
(Math.floor(Math.random()*255)+1).toString(16) +
(Math.floor(Math.random()*255)+1).toString(16);
	fill_color_b = "0x"+(Math.floor(Math.random()*255)+1).toString(16) +
(Math.floor(Math.random()*255)+1).toString(16) +
(Math.floor(Math.random()*255)+1).toString(16);
	lineStyle(1, fill_color_a, 100);
	colors = [fill_color_b, fill_color_a];
	alphas = [100, 100];
	ratios = [0, 255];
	matrix = {a:0, b:_root.gear_y_width*1.5, c:0, d:_root.gear_x_width*1.5, e:0, f:0, g:0, h:0, i:1};
	beginGradientFill("radial", colors, alphas, ratios, matrix);
	draw_gear(0, 0, gear_x_width, gear_y_width, gear_num_spokes, gear_inside, gear_outside);
	endFill();
}

```
