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 = rMath.cos(angleMath.PI/180);
var endy = rMath.sin(angleMath.PI/180);
// control:
// (angle-90 is used to give the correct sign)
var cx =endx + raMath.cos((angle-90)Math.PI/180);
var cy =endy + ra*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();