bitmap timer

by Highly
♥0 | Line 42 | Modified 2010-12-21 06:30:10 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.Event;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var rect:Rectangle=new Rectangle(0,0,stage.width,stage.height);
            var bm:BitmapData=new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000);
            addChild(new Bitmap(bm));
            bm.fillRect(rect, 0x000000);
            var out1:TextField = new TextField();
            out1.selectable=false;
            out1.y=20;
            out1.x=20;
            addChild(out1);
//
            var t:Timer=new Timer(20,0);
            t.addEventListener(TimerEvent.TIMER,tmr);
            t.start();
//
            var b:Boolean=true;
            function tmr(e:TimerEvent):void {
                 if (b) {
                         drw();
                         b=false;
                         } else {
                                clr();
                                b=true;
                                }
                        }
                        function drw():void {
                        bm.fillRect(bm.rect,0x000000);
                        }
                        function clr():void {
                            bm.fillRect(bm.rect,0xFFFFFF);
                        }                        
               }
       }
}