pastel rects
/**
* Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fcSl
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
graphics.beginFill(0);
graphics.drawRect(0,0,465,465);
addEventListener("enterFrame",function(e:*):void {
update();
});
c=new Sprite();
canvas= new BitmapData(465,465,true,0);
addChild(new Bitmap(canvas));
}
private var c:Sprite;
private var canvas:BitmapData;
private function update():void {
var mx:Number = mouseX;
var my:Number = mouseY;
var r:Sprite = newR();
c.addChild(r);
r.x=mx-Math.random()*r.width;
r.y=my-Math.random()*r.height;
var i:int=c.numChildren;
while(i--)
{
r=c.getChildAt(i) as Sprite;
r.rotation+=r.x|r.y;
r.alpha-=.2;
if(r.alpha<=0)c.removeChild(r);
}
canvas.lock();
canvas.draw(c);
canvas.unlock();
}
private function newR():Sprite {
var r:Sprite = new Sprite();
r.graphics.beginFill(0xFFFFFF*Math.random(),.1);
r.graphics.drawRect(0,0,Math.random()*30+20,Math.random()*60+20);
return r;
}
}
}