Ok this took me long but I finnaly got it. I used the pythagorean theorem for distance calculation to find the distance between the center of the stage and the mouse position, then I used a function that makes a circle for you to make a circle with a radius of the distance.
here is the source:
_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, 0×000000, 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, 0×000000, 100);
lineTo(_root._xmouse, _root._ymouse);
}
with (circle) {
clear();
lineStyle(1, 0×000000, 100);
}
with (circle2) {
clear();
lineStyle(1, 0×000000, 100);
}
drawCircle(circle2, x, y, 5);
drawCircle(circle, cx, cy, prox);
updateAfterEvent();
};
July 8, 2006 at 12:29 am |
Nice work! This could be the basis of lots of cool experiments.
Lee
July 8, 2006 at 2:51 am |
WOW! am I dreaming? or did Lee Brimelow just post in my newly opened blog? I have a question: The WordPress screws up the all the 0x’s and quotation marks. how do you take that off in your blog?
July 28, 2006 at 2:41 pm |
Awesome job on this one. I’m no big actionscripter… my proof of that statement you ask? Well, it took me a half hour to realize the 0x screw up that you already had in this post. I did have a question. I did the beginFill on the outer most circle. Would it be possible to add a mask of an image or a gradient? Great job again. You’re heading into Lee’s territory of greatness here.