flash on 2010-11-14

by stenpel
♥0 | Line 43 | Modified 2010-11-14 17:01:45 | MIT License
play

ActionScript3 source code

/**
 * Copyright stenpel ( http://wonderfl.net/user/stenpel )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/c0RK
 */

package {
    import flash.text.TextField;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private const N:int = 100;
        private const T:Number = 1000/60;
        private const W:Number = stage.stageWidth;
        private const H:Number = stage.stageHeight;
        
        private var tf:TextField;
        private var tftf:TextField;
        
        private var count:int = 0;
        private var timers:Vector.<Timer> = new Vector.<Timer>();
        
        public function FlashTest() {
            tf = new TextField();
            addChild(tf);
            tftf = new TextField();
            tftf.width = W;
            tftf.autoSize = "left";
            tftf.wordWrap = true;
            tftf.multiline = true;
            addChild(tftf);
            tftf.y = tftf.height + 5;
            
            var i:int;
            
            for (i=0; i < N; i++) {
               var t:Timer = new Timer(T);
               t.addEventListener(TimerEvent.TIMER, onTimer);
               t.start();
            }
        }
        
        private function onTimer(e:TimerEvent):void {
            count++;
            tf.text = count.toString();
            if(count % 3 == 0) {
                
                if(tftf.height > H) {
                    tftf.text = "";
                }

                tftf.appendText(count.toString()+" ");
            }
        }

    }
}