flash on 2010-5-13

by uepon24
♥0 | Line 23 | Modified 2010-05-13 00:27:21 | 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/QfhH
 */

package{
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class MouseClick extends Sprite{
		
		public function MouseClick(){
			//ステージにクリック・イベントのハンドラを登録する
			stage.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		private function onClick(e:MouseEvent):void{
			//半径をランダムでセット
			var nR:int = Math.ceil(Math.random() * 20) + 10;
			
			//色をランダムで選ぶ
			var color:int = Math.floor(Math.random() * 0xffffff);
			
			//円のクラスのインスタンスを作る
			var oneCircle:Sprite = new DrawCircle1(e.stageX, e.stageY, nR, color);
			
			//円のインスタンスを表示リストに追加する
			addChild(oneCircle);
		}
		
	}
	
}

import flash.display.Sprite;

class DrawCircle1 extends Sprite{
	public function DrawCircle1(centerX:int, centerY:int, r:int, color:int){
		//線の太さを2,色をcolorにセットする
		graphics.lineStyle(2,color);
		//centerX, centerYを中心とする半径nRの円を描く
		graphics.drawCircle(centerX, centerY, r);
	}
}