# Circle Gradient fill need help!

**URL:** <https://forum.kirupa.com/t/circle-gradient-fill-need-help/125680>\
**Category:** Uncategorized\
**Created:** [October 16, 2004, 7:27am UTC](https://forum.kirupa.com/t/circle-gradient-fill-need-help/125680 "2004-10-16T07:27:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johlanh](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@johlanh](https://forum.kirupa.com/u/johlanh)\
**Post date:** [October 16, 2004, 7:27am UTC](https://forum.kirupa.com/t/circle-gradient-fill-need-help/125680/1 "2004-10-16T07:27:56Z")

</div>

I want to create a dynamicly gradient fill of a circle with action script and I’m stuck. I know how to create one for a square but when I’m changing the gradient to fill the circle it doesn’t do anything, please help.

this is what I’ve found for square:

\_root.createEmptyMovieClip( “grad”, 1 );  
with ( \_root.grad )

```
          {

          colors = [0xDDDDDD, 0xFFFFFF];
          alphas = [100, 100];
          ratios = [0, 0xCF];
          matrix = { a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1 };
          beginGradientFill( "linear", colors, alphas, ratios, matrix );
          moveto(100,100);
          lineto(100,300);
          lineto(300,300);
          lineto(300,100);
          lineto(100,100);
          endFill();

          }

```

and this is what I’m trying on circle:

MovieClip.prototype.drawCircle = function(r, x, y) {  
this.moveTo(x+r, y);  
a = Math.tan(22.5 \* Math.PI/180);  
for (var angle = 45; angle\<=360; angle += 45) {  
// endpoint:  
var endx = r_Math.cos(angle_Math.PI/180);  
var endy = r_Math.sin(angle_Math.PI/180);  
// control:  
// (angle-90 is used to give the correct sign)  
var cx =endx + r_a_Math.cos((angle-90)_Math.PI/180);  
var cy =endy + r_a\*Math.sin((angle-90)\*Math.PI/180);  
this.curveTo(cx+x, cy+y, endx+x, endy+y);  
}  
}  
var c80 = this.createEmptyMovieClip(“c”, 1);  
c80.lineStyle(3, 0xaaaaaa, 100);  
colors = [0xDDDDDD, 0xFFFFFF];  
alphas = [100, 100];  
ratios = [0, 0xDF];  
matrix = { a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1 }; beginGradientFill( “linear”, colors, alphas, ratios, matrix );  
c80.drawCircle(80, 100, 100);  
c80.endFill();
