[SWF(width = 500, height=500, backgroundColor=0x000000)]
var clockNum:int = 100;
var clocks:Vector.<Function> = new Vector.<Function>(clockNum, true);
var clockContainer:Sprite = Sprite(addChild(new Sprite()));
clockContainer.x = stage.stageWidth / 2;
clockContainer.y = stage.stageHeight / 2;
buildClocks();
runClocks();
function buildClocks():void{
for (var i:int = 0; i<clockNum; i++){
var theta:Number = Math.random() * Math.PI * 2;
var radius:Number = Math.random() * 200;
var xp:Number = radius * Math.cos(theta);
var yp:Number = radius * Math.sin(theta);
clocks[i] = makeClock(xp,yp,Math.random() * Math.PI * 2);
}
}
function runClocks():void{
addEventListener(Event.ENTER_FRAME, onRunClocks);
}
function onRunClocks(evt:Event):void{
for (var i:int = 0; i<clockNum; i++){
clocks[i]();
}
clockContainer.rotationX = clockContainer.mouseY / 30;
clockContainer.rotationY = -clockContainer.mouseX / 30;
}
function makeClock(x:Number, y:Number, time:Number=0):Function{
var radius:Number = Math.random() * 20 + 5;
var border:Number = radius * 0.2;
var smallRadius:Number = radius - radius * 0.3;
var clock:Sprite = Sprite(clockContainer.addChild(new Sprite()));
clock.x = x;
clock.y = y;
clock.z = 100 - Math.random() * 200;
clock.rotationX = Math.random() * 40 - 20;
clock.rotationY = Math.random() * 40 - 20;
clock.rotationZ = Math.random() * 360;
return function():void{
with (clock.graphics){
clear();
lineStyle(1,0xFFFFFF);
drawCircle(0,0,radius + border);
var xp:Number = smallRadius * Math.cos(time/2);
var yp:Number = smallRadius * Math.sin(time/2);
moveTo(0,0);
lineTo(xp, yp);
xp = radius * Math.cos(time);
yp = radius * Math.sin(time);
moveTo(0,0);
lineTo(xp, yp);
}
time+=0.1;
}
}
You can go check the swf out at wonderfl.net…

Hahahaha, that’s awesome.
That way of doing functions return functions is really fast to code, no? Nice work mate!
could have used random time increment too