forked from: Bubbles
// forked from el_falcon's Bubbles
package {
import flash.display.*;
import flash.events.*;
[SWF(width = 465, height = 465, backgroundColor = 0xfee9dd)]
public class FlashTest extends Sprite {
private var shapes:Array = [];
public function FlashTest() {
// write as3 code here..
for(var i:uint=0; i<300; i++) {
var s:Shape = new Shape();
addChild(s);
var g:Graphics = s.graphics;
g.lineStyle(Math.round(Math.random()*15), Math.round(Math.random()*0xffffff));
var radius:Number = Math.round(Math.random()*40);
g.drawCircle(0, 0, radius);
s.x = Math.round(Math.random()*stage.width);
s.y = Math.round(Math.random()*stage.height);
s.alpha = (81 - radius) / 85;
s.cacheAsBitmap = true;
shapes.push({shape: s, speed: (81 - radius)/40});
}
stage.addEventListener(Event.ENTER_FRAME, move);
}
private function move (e:Event):void {
for(var i:uint = 0; i<shapes.length; i++) {
var s:Object = shapes[i];
s.shape.y -= s.speed;
s.shape.x -= 3;
if( s.shape.x + s.shape.width < 0 ) s.shape.x = stage.stageWidth + 50;
if(s.shape.y + s.shape.height < 0) s.shape.y = stage.stageHeight + 50;
}
}
}
}