# Circles and Ellipses with curveTo in Flash 6 (ActionScript 1.0)

Drawing prototype to programmatically create circles and ellipses. Pass null for lineRGB or fillRGB when lines or fills are not needed.

Code:

```MovieClip.prototype.createEllipse = function(instanceName, depth, x, y, radiusX, radiusY, lineThickness, lineRGB, lineAlpha, fillRGB, fillAlpha) {
var controlX, controlY, anchorX, anchorX, angle, i;
var dr = 2 - Math.cos(Math.PI / 8);
var contraX = radiusX * dr;
var contraY = radiusY * dr;
var ellipse_mc = this.createEmptyMovieClip(instanceName, depth);
ellipse_mc._x = x;
ellipse_mc._y = y;
if(lineRGB) { ellipse_mc.lineStyle(lineThickness, lineRGB, lineAlpha); }
if(fillRGB) { ellipse_mc.beginFill(fillRGB, fillAlpha); }
for(i = 1; i <= 8; i++) {
angle = i * Math.PI / 4;
controlX = contraX * Math.cos(angle - Math.PI / 8);
controlY = contraY * Math.sin(angle - Math.PI / 8);
ellipse_mc.curveTo(controlX, controlY, anchorX, anchorY);
}
ellipse_mc.endFill();
}
```

This example was created using the following code:

```this.createEmptyMovieClip('whiteboard_mc', 1);
this.whiteboard_mc._x = Stage.width / 2;
this.whiteboard_mc._y = Stage.height / 2;
this.whiteboard_mc.createEllipse('ellipse_mc1', 1, 0, -50, 90, 110, 2, 0x00ffff, 100, 0x00ffff, 50);
this.whiteboard_mc.createEllipse('ellipse_mc2', 2, 43, 25, 90, 110, 2, 0xff00ff, 100, 0xff00ff, 50);
this.whiteboard_mc.createEllipse('ellipse_mc3', 3, -43, 25, 90, 110, 2, 0xffff00, 100, 0xffff00, 50);
this.whiteboard_mc.ellipse_mc2._rotation = -60;
this.whiteboard_mc.ellipse_mc3._rotation = -120;
```