Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
Drawing A Circle (Using A Custom Function)  

Download .fla

How to draw this circle with Actionscript.

Actionscript

this.createEmptyMovieClip("my_circle_mc", 1);
my_circle_mc._x = 75;
my_circle_mc._y = 75;

drawCircle(my_circle_mc, 100, 4, 0xCC66FF, 100, 0xFFCCCC, 100);

function drawCircle(target_mc:MovieClip, radius:Number, lineHeight:Number, lineColor:Number, lineAlpha:Number, fillColor:Number, fillAlpha:Number):Void {
var x:Number = radius;
var y:Number = radius;
with (target_mc) {
beginFill(fillColor, fillAlpha);
lineStyle(lineHeight, lineColor, lineAlpha);
moveTo(x + radius, y);

curveTo(radius + x, Math.tan(Math.PI / 8) * radius + y, Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y);
curveTo(Math.tan(Math.PI / 8) * radius + x, radius + y, x, radius + y);

curveTo(-Math.tan(Math.PI / 8) * radius + x, radius+ y, -Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y);
curveTo(-radius + x, Math.tan(Math.PI / 8) * radius + y, -radius + x, y);

curveTo(-radius + x, -Math.tan(Math.PI / 8) * radius + y, -Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y);
curveTo(-Math.tan(Math.PI / 8) * radius + x, -radius + y, x, -radius + y);

curveTo(Math.tan(Math.PI / 8) * radius + x, -radius + y, Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y);
curveTo(radius + x, -Math.tan(Math.PI / 8) * radius + y, radius + x, y);
endFill();
}
}


How The Actionscript Works





© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us