x軸の移動

by _wonder forked from base (diff: 21)
♥0 | Line 36 | Modified 2010-04-27 18:25:46 | MIT License
play

ActionScript3 source code

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

// forked from _wonder's base
package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Velocity extends Sprite {
    		private var ball:Ball;
    		private var vx:Number = 2;
    		
        public function Velocity() {
            init();
        }
        
        private function init():void{
        		ball = new Ball();
        		addChild( ball );
        		ball.x = 50;
        		ball.y = 100;
        		addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function onEnterFrame(e:Event):void {
        		ball.x += vx;
        }
    }
}

import flash.display.Sprite;

class Ball extends Sprite {
	public var radius:Number;
	public var color:uint;
	
	public function Ball(radius:Number=40, color:uint=0Xff0000){
		this.radius = radius;
		this.color = color;
		init();
	}
	
	public function init():void {
		graphics.beginFill(color);
		graphics.drawCircle(0, 0, radius);
		graphics.endFill();
	}
}

Forked