Return to Snippet

Revision: 49997
at August 4, 2011 02:27 by adrianparr


Initial Code
drawCircle(this, 300, 300, 16, 0x0000FF);

function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number, color:Number):Void {
	mc.beginFill(color);
	mc.moveTo(x+r, y);
	mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, 
	Math.sin(Math.PI/4)*r+y);
	mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
	mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, 
	Math.sin(Math.PI/4)*r+y);
	mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);
	mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, 
	-Math.sin(Math.PI/4)*r+y);
	mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);
	mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, 
	-Math.sin(Math.PI/4)*r+y);
	mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);
	mc.endFill();
}

Initial URL


Initial Description
I recently has to work on an AS2 project (yuk) and create circles dynamically. Here is a handy function for this.

Initial Title
AS2 Draw Circle

Initial Tags


Initial Language
ActionScript