Thanks to everyone who helped out a few weeks ago when I
asked about drawing a ring or doughnut shape.
Here is AS3 code to do this, based on the AS1 code in this post
http://chattyfig.figleaf.com/pipermail/flashcoders/2005-October/152572.html
private function drawRing (r1:Number, r2:Number, x:Number, y:Number):void {
var TO_RADIANS:Number = Math.PI/180;
circle.graphics.moveTo(r1+x,0+y);
var endx:Number;
var endy:Number;
var ax:Number;
var ay:Number;
// draw the 30-degree segments
var a:Number = 0.268; // tan(15)
for (var i:uint=0; i < 12; i++) {
endx = r1*Math.cos((i+1)*30*TO_RADIANS);
endy = r1*Math.sin((i+1)*30*TO_RADIANS);
ax = endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS);
ay = endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS);
circle.graphics.curveTo(ax+x, ay+y, endx+x, endy+y);
}
// cut out middle (go in reverse)
circle.graphics.moveTo(r2+x, 0 +y);
for (i=12; i > 0; i--) {
endx = r2*Math.cos((i-1)*30*TO_RADIANS);
endy = r2*Math.sin((i-1)*30*TO_RADIANS);
ax = endx+r2*(0-a)*Math.cos(((i-1)*30-90)*TO_RADIANS);
ay = endy+r2*(0-a)*Math.sin(((i-1)*30-90)*TO_RADIANS);
circle.graphics.curveTo(ax+x, ay+y, endx+x, endy+y);
}
}
Regards
David
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com