forked from: flash on 2009-4-6
// forked from no48's flash on 2009-4-6
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.utils.*;
public class FlashTest extends MovieClip {
private var t : Timer;
private var bmd : BitmapData = new BitmapData (465, 465);
private var bmp : Bitmap;
private var bf:BlurFilter = new BlurFilter (2, 2, 1);
private var ct:ColorTransform = new ColorTransform (1, 1, 1, 1, 10, 15, 20);
public function FlashTest() {
// write as3 code here..
t = new Timer(500);
t.addEventListener(TimerEvent.TIMER, setTet);
t.start();
addEventListener(Event.ENTER_FRAME, loop);
}
private function setTet(e:TimerEvent):void{
for (var i:int = 0; i < 1 + Math.random () * mouseX / 10; i++)
textToBitmap(String.fromCharCode(int ("a".charCodeAt(0) + Math.random () *
("z".charCodeAt(0) - "a".charCodeAt(0)))),
new TextFormat("Helvetica",
int (20 + 40 * Math.random ()),
null,true));
if (bmp == null) {
bmp = new Bitmap(bmd);
addChild(bmp);
}
t.delay = Math.min (Math.max (10, 500 - mouseX), 500);
}
private function loop (e:Event):void {
bmd.applyFilter (bmd, bmd.rect, bmd.rect.topLeft, bf);
bmd.colorTransform (bmd.rect, ct);
}
private var m:Matrix = new Matrix;
private function textToBitmap(text : String, tfmt : TextFormat) : void {
var tf : TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.defaultTextFormat = tfmt;
tf.text = text;
//tf.background = false;
m.tx = 465 * Math.random ();
m.ty = 465 * Math.random ();
bmd.draw(tf, m);
}
}
}