code:
SW = Stage.width;
SH = Stage.height;
kRadiansToDegrees = 180/Math.PI;
kDegreesToRadians = Math.PI/180;
MovieClip.prototype.drawCircle = function(x,y,radius)
{
var r = radius;
var theta = 45*kDegreesToRadians;
var cr = radius/Math.cos(theta/2);
var angle = 0;
var cangle = -theta/2;
this.moveTo(x+r, y);
for (var i=0;i < 8;i++)
{
angle += theta;
cangle += theta;
var endX = r*Math.cos (angle);
var endY = r*Math.sin (angle);
var cX = cr*Math.cos (cangle);
var cY = cr*Math.sin (cangle);
this.curveTo(x+cX,y+cY, x+endX,y+endY);
}
}
moveCircle = function()
{
var dx = this.tx - this._x;
var dy = this.ty - this._y;
if (Math.abs(dx) < 1 && Math.abs(dy) < 1)
{
var range = Math.random()*(outer_mc.rad - this.rad);
var a = Math.random()*2*Math.PI;
this.tx = SW/2 + Math.cos(a) * range;
this.ty = SH/2 + Math.sin(a) * range;
}
else {
this._x += dx/5;
this._y += dy/5;
}
}
_root.createEmptyMovieClip("outer_mc", 1);
_root.createEmptyMovieClip("inner_mc1", 2);
_root.createEmptyMovieClip("inner_mc2", 3);
outer_mc._x = SW/2;
outer_mc._y = SH/2;
outer_mc.rad = 300;
outer_mc.clear();
outer_mc.lineStyle(2, 0xFF0000, 100);
outer_mc.drawCircle(0,0,outer_mc.rad);
inner_mc1._x = inner_mc1.tx = W/2;
inner_mc1._y = inner_mc1.ty = SH/2;
inner_mc1.rad = 50;
inner_mc1.clear();
inner_mc1.tx =
inner_mc1.lineStyle(2, 0x00FF00, 100);
inner_mc1.drawCircle(0,0,inner_mc1.rad);
inner_mc1.onEnterFrame = moveCircle;
inner_mc2._x = inner_mc2.tx = SW/2;
inner_mc2._y = inner_mc2.ty = SH/2;
inner_mc2.rad = 64;
inner_mc2.clear();
inner_mc2.lineStyle(2, 0x0000FF, 100);
inner_mc2.drawCircle(0,0,inner_mc2.rad);
inner_mc2.onEnterFrame = moveCircle;