flash on 2010-5-17

by yd_niku
♥0 | Line 29 | Modified 2010-05-17 19:37:10 | MIT License
play

ActionScript3 source code

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

package {
import flash.utils.*;
import flash.events.*;
    import flash.display.*;
    import flash.text.*;
    public class FlashTest extends Sprite {
        
        private var _timer:Timer = new Timer(1000);
        private var _ball:Shape = new Shape();
        private var _monitor:TextField = new TextField();
        
        public function FlashTest() {
            _ball.graphics.beginFill(Math.random()*0xFFFFFF);
            _ball.graphics.drawCircle(0,0,30);
            _ball.graphics.endFill();
            addChild(_ball);
            _timer.addEventListener(TimerEvent.TIMER,timerHandler);
            _timer.start();
            
            addChild( _monitor );
            _monitor.width =465;
            
            stage.addEventListener(MouseEvent.CLICK, resetHandler);
        }
        private function timerHandler(e:TimerEvent):void{
            _ball.x = Math.random()*465;
            _ball.y = Math.random()*465;
        }
        private function resetHandler(e:Event):void{
            _timer.reset();
        }
    }
}