flash on 2009-2-27
/**
* Copyright awef ( http://wonderfl.net/user/awef )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tuwf
*/
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;
y = defaultY + p.y;
}
}