In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

# forked from: How can I draw a circle with dashed line/stroke?

```Hi! Why don't you use the DrawArc class below?
How can I draw a circle with dashed line/stroke?
Using a for cycle and using the equation of the circle wouldn't it be too slow?```
by SoWhat1983 22 Dec 2009

## Tags

Embed
```/**
* Copyright SoWhat1983 ( http://wonderfl.net/user/SoWhat1983 )
*/

// Hi! Why don't you use the DrawArc class below?

// forked from maesy's How can I draw a circle with dashed line/stroke?
//How can I draw a circle with dashed line/stroke?
//Using a for cycle and using the equation of the circle wouldn't it be too slow?
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.CapsStyle;
import flash.display.JointStyle;

public class DashedCircle extends Sprite {
private var shape:Shape;

public function DashedCircle() {
circle();
}

private function circle():void{
shape = new Shape();
shape.graphics.beginFill(0xFFcccc, 1);
//Can i set a dashed line style?
//	    shape.graphics.lineStyle(2, 0x000000, 1, true, LineScaleMode.NONE, CapsStyle.SQUARE, JointStyle.MITER, 3);
shape.graphics.drawCircle(0, 0, int(stage.stageWidth / 2));
shape.graphics.endFill();
//            shape.x = stage.stageWidth/2;
//            shape.y = stage.stageHeight/2;

var dashedCircle:Sprite = new Sprite();
var arcAngle:Number            =  4;
var dashedLineColor:uint       =  0x666666;
var dashedLineThickness:Number =  4;

for(var i:Number=0;i<360/(arcAngle*2);i++){
var a:drawArc = new drawArc(0,0,stage.stageWidth / 2,i*(arcAngle*2),arcAngle,0x000000,dashedLineThickness,dashedLineColor);
}
dashedCircle.x=dashedCircle.y=stage.stageWidth/2;

}
}
}

import flash.display.*;
class drawArc extends Sprite
{
public function drawArc(baseX:Number, baseY:Number, radius:Number, startAngle:Number, arcAngle:Number, fillColor:uint,lineThickness:Number,lineColor:uint):void {

var segAngle:Number, theta:Number, angle:Number, angleMid:Number, segs:Number, ax:Number, ay:Number, bx:Number, by:Number, cx:Number, cy:Number, return_arr:Array;

segs = Math.ceil(Math.abs(arcAngle)/45);
segAngle = arcAngle/segs;

theta = -(segAngle/180)*Math.PI;
angle = -(startAngle/180)*Math.PI;

// angle += theta;

ax = 0;
ay = 0;
angleMid = angle-(theta/2);

with(graphics){
beginFill(fillColor);
lineStyle(lineThickness,lineColor);
//			moveTo(0,0);
//			lineTo(bx, by);
moveTo(bx, by);
}

if (segs>0) {
for (var i:int = 0; i<segs; i++) {
angle += theta;
angleMid = angle-(theta/2);