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, 20));
}
}
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 = Math.round(Math.random() * 255 * 255 * 255);
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.75);
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) - 90 * Math.PI / 180);
x = defaultX + p.x + p.y;
y = defaultY - p.x + p.y;
this.scaleX = 1 / ((dist+10)* 0.03125);
this.scaleY = 1 / ((dist+10)* 0.03125);
}
}