alright guys. pop quiz over!, to make the circumeter, paste this code on the first frame of the movie.
_root.createEmptyMovieClip("circle", 1);
_root.createEmptyMovieClip("circle2", 2);
_root.createEmptyMovieClip("circle3", 3);
_root.createEmptyMovieClip("line", 4);
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
with (mc) {
moveTo(x+r, y);
curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);
curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);
curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);
}
}
circle3.lineStyle(1, 0x000000, 100);
drawCircle(circle3, 275, 200, 5);
_root.onMouseMove = function() {
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
var cx:Number = 275;
var cy:Number = 200;
var prox:Number = Math.sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy));
with (line) {
clear();
moveTo(275, 200);
lineStyle(1, 0x000000, 100);
lineTo(_root._xmouse, _root._ymouse);
}
with (circle) {
clear();
lineStyle(1, 0x000000, 100);
}
with (circle2) {
clear();
lineStyle(1, 0x000000, 100);
}
drawCircle(circle2, x, y, 5);
drawCircle(circle, cx, cy, prox);
updateAfterEvent();
};
a whole, bug-free circmeter in only 43 lines!!!
AND to prove im the master of draw API, to make a cross hair put this code on the first frame.
_root.createEmptyMovieClip("circle", 1);
_root.createEmptyMovieClip("xLine", 2);
_root.createEmptyMovieClip("yLine", 3);
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
with (mc) {
moveTo(x+r, y);
curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);
curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);
curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);
}
}
with (xLine) {
lineStyle(1, 0x000000);
moveTo(0, Stage.height/2);
lineTo(Stage.width, Stage.height/2);
}
with (yLine) {
lineStyle(1, 0x000000);
moveTo(Stage.width/2, 0);
lineTo(Stage.width/2, Stage.height);
}
_root.onMouseMove = function() {
with (circle) {
clear();
lineStyle(1, 0x000000);
}
drawCircle(circle, _root._xmouse, _root._ymouse, 50);
xLine._y = _root._ymouse-Stage.height/2;
yLine._x = _root._xmouse-Stage.width/2;
updateAfterEvent();
};