forked from: flash on 2009-2-27
// forked from awef's flash on 2009-2-27
package
{
import flash.display.*;
import flash.events.*;
public class main extends Sprite
{
private var obj:Array = new Array();
private function add(o:DisplayObject):void
{
obj.push(o);
stage.addChild(o);
}
function main()
{
for(var ix:uint = 10; ix < 35; ix++)
{
for(var iy:uint = 10; iy < 35; iy++)
{
add(new eyeball(ix * 10 + 5, iy * 10 + 5, 4, 30));
}
}
stage.addEventListener(Event.ENTER_FRAME, frame);
}
private function frame(e:Event):void
{
for(var i:String in obj)
{
obj[i].run();
}
}
}
}
import flash.display.*;
import flash.geom.Point;
class eyeball extends Shape
{
private var defaultX:uint;
private var defaultY:uint;
private var r:uint;
private var s:uint;
private var c:uint = 0x0000;
function eyeball(arg_x:uint, arg_y:uint, arg_r:uint, arg_s:uint)
{
defaultX = arg_x;
defaultY = arg_y;
x = arg_x;
y = arg_y;
r = arg_r;
s = arg_s;
graphics.beginFill(c, 0.3);
graphics.drawCircle(0, 0, r);
graphics.endFill();
}
public function run():void
{
var dist:Number = Point.distance(new Point(defaultX, defaultY), new Point(stage.mouseX, stage.mouseY));
var p:Point = Point.polar((dist < s)? dist : s, -Math.atan2(defaultX - stage.mouseX, defaultY - stage.mouseY) - 180 * Math.PI / 180);
x = defaultX + p.x/1.5;
y = defaultY + p.y/1.5;
}
}