/**
* Copyright phi16 ( http://wonderfl.net/user/phi16 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eslY
*/
// forked from phi16's Template
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class Tp extends Sprite {
public var spr:Sprite=new Sprite();
public var ra:Number=0;
public var ba:Array=new Array();
public var p:Block=new Block();
public function Tp(){
this.addChild(spr);
this.addEventListener(Event.ENTER_FRAME,frame);
this.addEventListener(MouseEvent.MOUSE_MOVE,moved);
}
public function frame(e:Event):void{
spr.graphics.clear();
spr.graphics.beginFill(0x000000);
spr.graphics.drawRect(0,0,465,465);
spr.graphics.endFill();
for(var i:int=0;i<ba.length;i++){
ba[i].t+=0.5;
ba[i].draw(spr);
}
while(ba[0].t>40)ba.shift();
ra++;
}
public function moved(e:MouseEvent):void{
if(ra%2 || (ba.length && ba[ba.length-1].p==ra))return;
var r:int=ba.length;
ba[r]=new Block();
ba[r].x=mouseX;
ba[r].y=mouseY;
ba[r].w=10+Math.random()*90;
ba[r].h=10+Math.random()*90;
ba[r].t=0;
ba[r].p=ra;
var colr:int,colg:int,colb:int;
colr=(Math.sin(ra*Math.PI/180)+1)*255/2;
colg=(Math.sin((ra+120)*Math.PI/180)+1)*255/2;
colb=(Math.sin((ra-120)*Math.PI/180)+1)*255/2;
ba[r].c=colr*256*256+colg*256+colb;
}
}
}
import flash.display.Sprite;
class Block{
public var x:Number,y:Number,w:Number,h:Number;
public var t:Number,c:uint,p:Number;
public function draw(spr:Sprite):void{
spr.graphics.beginFill(c,1-t/40);
var f:Number=-Math.cos(t*40*Math.PI/180)/(t+1);
spr.graphics.drawRect(x-w/2-f*w/2,y-h/2-f*h/2,w+f*w,h+f*h);
spr.graphics.endFill();
}
}