forked from: sbcr_1_1

by ushisantoasobu forked from sbcr_1_1 (diff: 63)
♥0 | Line 43 | Modified 2010-11-02 16:37:02 | MIT License
play

ActionScript3 source code

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

// forked from ushisantoasobu's sbcr_1_1
package {
    import flash.geom.Point;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.Sprite;
    import flash.events.MouseEvent;       
    
    public class FlashTest extends Sprite {
        
        public var timer:Timer;
        public var basic_bal:ball;
        public var koko:Point;
        public var bure_x:int;
        public var bure_y:int;
        
        public function FlashTest() {
            
            basic_bal = new ball(0x000066);
            addChild(basic_bal);
            basic_bal.x = 40;
            basic_bal.y = 40;
            
            stage.addEventListener(MouseEvent.CLICK, clickEventHandler);
            
            timer = new Timer(33);
            timer.addEventListener(TimerEvent.TIMER, timerEventListener);
            timer.start();
            
        }
        
        public function clickEventHandler(e:MouseEvent):void{
            koko = new Point();
            koko.x = this.mouseX;
            koko.y = this.mouseY;
            bure_x = Math.random() * 10 + 5;
            bure_y = Math.random() * 10 + 5;
        }     
        
        public function timerEventListener(e:TimerEvent):void{
                
                basic_bal.x += (koko.x - basic_bal.x) / bure_x;
                basic_bal.y += (koko.y - basic_bal.y) / bure_y;           

        }

        
    }
}



import flash.display.Sprite;

class ball extends Sprite{
    public function ball(num:Number){
        this.graphics.beginFill(num);
        this.graphics.drawCircle(0, 0, 20);
        this.graphics.endFill();
    }

}