flash on 2010-1-13

by uepon24
♥0 | Line 38 | Modified 2010-01-14 00:20:41 | MIT License
play

ActionScript3 source code

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

package {
	import flash.display.Sprite;
	import flash.events.Event;
	
	[SWF(frameRate="30", width="465", height="465")]
	public class Animation extends Sprite {
		private var _circle:Circle;
		//コンストラクタ
		public function Animation(){
			//クラスCircleのインスタンスを作る
			_circle = new Circle(10);
			_circle.alpha = 0.25;
			_circle.vx = 3;
			_circle.vy = 4;
			
			//最初の位置をwonderflの画面の中央にセット
			_circle.x = 465 / 2;
			_circle.y = 465 / 2;
			
			//表示リストに追加
			addChild(_circle);
			
			//1フレーム毎に実行する処理にenterFrameHandlerを追加する
			addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 0 , true);
		}
		
		private function enterFrameHandler(event:Event){
			//1フレーム分動かす
			_circle.move();
			trace(_circle.y);
			//if(_circle.y > 465){
			//_circle.y = 465/2;
			//_circle.x = 465/2;
			//}
		}
	}
}

import flash.display.Sprite;

class Circle extends Sprite{
	public var vx:Number;
	public var vy:Number;
	public var radius:Number;
	//コンストラクタ
	public function Circle(_radius:Number, _fillColor:uint = 0x000000){
		//塗り_fillCollr, 半径_radiusの円
		graphics.beginFill(_fillColor);
		graphics.drawCircle(0, 0, _radius);
		graphics.endFill();
		//半径の大きさをパブリックな変数に保存しておく
		radius = _radius;
	}
	
	public function move():void{
		x += vx;
		y += vy;
	}
}