Wordwave
another Bit101 code
This one is AS3 version.
/*
another Bit101 code
This one is AS3 version.
*/
package {
import flash.display.Sprite;
[SWF(backgroundColor="#000000", frameRate=30)]
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var _wave:Wordwave = new Wordwave();
addChild(_wave);
}
}
}
import flash.display.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.*;
class Wordwave extends Sprite
{
private var posX :Number = 0;
private var posY :Number = 0;
private var count :Number = 0;
private var speed :Number = 0;
private var a :Number = 0;
private var r :Number = 0;
private var g :Number = 0;
private var b :Number = 0;
private var rs :Number = 0;
private var gs :Number = 0;
private var bs :Number = 0;
public var tf:TextField;
private var _ready :Boolean = true;
private var _atfList :Array = [];
public function Wordwave()
{
_init();
this.addEventListener(Event.ENTER_FRAME, render);
}
private function _init():void
{
posX = posY = count = a = r = g = b = 0;
speed = Math.random()*.2+.1;
rs = Math.random()*.2+.1;
gs = Math.random()*.2+.1;
bs = Math.random()*.2+.1;
}
private function render(event:Event):void
{
if(_ready)
{
tf = new TextField();
tf.x = posX;
tf.y = posY;
addChild(tf);
_atfList.push(tf);
}
else
{
_atfList[count].x = posX;
_atfList[count].y = posY;
}
_atfList[count].text = Math.random()>.5 ? "1" : "0";
var red:Number = Math.sin(r += rs)*127+128;
var green:Number = Math.sin(g += gs)*127+128;
var blue:Number = Math.sin(b += bs)*127+128;
var col:Number = red << 16 | green << 8 | blue;
_atfList[count].setTextFormat(new TextFormat("_sans", Math.sin(a += speed)*16+18, col));
_atfList[count].autoSize = "left";
_atfList[count].height = _atfList[count].textHeight;
_atfList[count].y = posY - _atfList[count].height/2;
posX += _atfList[count].width;
count++;
if (posX>stage.stageWidth) {
posX = 0;
posY += 24;
if (posY>stage.stageHeight) {
_init();
_ready = false;
}
}
}
}