Zig Zag TextField
/**
* Copyright shapevent ( http://wonderfl.net/user/shapevent )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/etdF
*/
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class ZigZag extends MovieClip {
private var txt:TextField;
private var count:int;
public function ZigZag(){
// init
txt = TextField(addChild(new TextField()));
txt.text = "";
txt.width = 190;
txt.height = 400;
txt.multiline = true;
count = 1;
addEventListener(Event.ENTER_FRAME, onCountUp);
}
// private methods
private function render():void{
var line:String = int(count).toString(2);
while(line.length <31){
line = "0" + line;
}
txt.appendText(line + "\n");
txt.scrollV= txt.maxScrollV;
}
private function onCountUp(evt:Event):void {
count *= 2;
render();
if (count ==0x40000000){
removeEventListener(Event.ENTER_FRAME, onCountUp);
addEventListener(Event.ENTER_FRAME, onCountDown);
}
}
private function onCountDown(evt:Event):void {
count /= 2;
render();
if (count ==1){
addEventListener(Event.ENTER_FRAME, onCountUp);
removeEventListener(Event.ENTER_FRAME, onCountDown);
}
}
}
}