I found this code in AS2. It draws an outline of a circle:
var origin = {x: 200, y: 200}; // the point at the centre of the circle
var radius = 100; // how big the circle is
this.createEmptyMovieClip("circle_mc", 1); // a clip to hold the drawing
this.circle_mc.lineStyle(3, 0xff0000, 100); // a 3pt red line is used to draw the circle
this.circle_mc.moveTo(origin.x, origin.y - radius); // move to the top of the circle to start
this.circle_mc.i = -Math.PI / 2; // set the starting angle
this.circle_mc.onEnterFrame = function() {
var x = origin.x + Math.cos(this.i) * radius; // calculate the next x and y points
var y = origin.y + Math.sin(this.i) * radius;
this.lineTo(x, y); // and draw a line to it
if (this.i < 3 * Math.PI / 2) { // if we have not yet got back to the start point
this.i += Math.PI / 180; // keep going
} else { // we're done
delete this.onEnterFrame;
}
};
I’m only just embarking on making the move to AS3 - can anyone help me convert this over?
Much appreciated.