test level 1+ orange/white
// forked from kunzo's test level 1+
// forked from kunzo's test level 1
// write as3 code here..
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
public class Main extends MovieClip
{
private const BG_COLOR = 0xFF9900;
private const SCALE_IR:Number = 1.05;
private const ALPHA_DD:Number = 0.1;
private const MAX_CHILDREN:uint = 100;
private var animationContainer:Sprite = new Sprite();
private var prevX:Number = 0;
public function Main():void
{
addChild(animationContainer);
buildBG(BG_COLOR);
addEventListener(Event.ENTER_FRAME, animate);
}
private function animate(e:Event):void
{
var radius:Number = Math.floor((Math.random() * stage.stageWidth) / 4);
if(this.mouseX != prevX) makeCircle(this.mouseX, this.mouseY, radius);
else makeCircle(Math.random() * stage.stageWidth, Math.random() * stage.stageHeight, radius);
prevX = this.mouseX;
for(var i:uint = 0; i < animationContainer.numChildren; i++)
{
var shape:Shape = animationContainer.getChildAt(i) as Shape;
if(shape)
{
shape.alpha -= ALPHA_DD;
if(shape.alpha <= 0) animationContainer.removeChildAt(i);
else shape.scaleX = shape.scaleY = shape.scaleX * SCALE_IR;
}
}
if(animationContainer.numChildren > MAX_CHILDREN) removeEventListener(e.type, arguments.callee);
}
private function makeCircle(x:Number = 10, y:Number = 10, radius:Number = 10, color:Number = 0):void
{
var shape:Shape = new Shape();
shape.graphics.beginFill(0xFFFFFF);
// shape.graphics.lineStyle(0, color);
shape.graphics.drawCircle(0, 0, radius);
shape.graphics.endFill();
shape.x = x;
shape.y = y;
animationContainer.addChild(shape);
}
private function getRandomColor(rMax:uint = 255, gMax:uint = 255, bMax:uint = 255):Number
{
var r:Number = Math.random() * rMax;
var g:Number = Math.random() * gMax;
var b:Number = Math.random() * bMax;
return r<<16 | g<<8 | b;
}
private function buildBG(color:Number):void
{
var shape:Shape = new Shape();
shape.graphics.beginFill(color);
shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
shape.graphics.endFill();
addChildAt(shape, 0);
}
}
}