// forked from fladdict's forked from: code on 2008-12-17
// forked from fladdict's code on 2008-12-17
// write as3 code here..
// Study for color generation.
package{
import flash.display.*
import flash.events.*
public class Sketch01 extends Sprite
{
public var lines:Array;
public var canvas:BitmapData;
public function Sketch01():void
{
lines = [];
var yPos:Number = 0;
while(yPos<stage.stageHeight){
var h:Number = Math.round(10 + normRand()*18);
var bmd:BitmapData = new BitmapData(stage.stageWidth, h, false, 0);
var bm:Bitmap = new Bitmap(bmd);
bm.y = yPos;
addChild(bm);
yPos += bm.height;
lines.push(bm);
}
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function enterFrameHandler(e:Event):void
{
var n:int = lines.length;
for(var i:int=0; i<n; i++)
{
var bm:Bitmap = lines[i];
var bmd:BitmapData = bm.bitmapData;
bmd.fillRect(bmd.rect, getColor());
}
}
protected function getColor():int
{
var r:int = Math.random()*255;
var g:int = Math.random()*r;
var b:int = Math.random()*g;
return r<<16 | g<<16 | b;
}
protected function normRand():Number
{
return (Math.random()+Math.random()+Math.random()+Math.random()+Math.random())/5 - 0.5;
}
}
}