In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ball集合

練習
Flash Math & Physics Design:ActionScript 3.0による数学・物理学表現[入門編]
http://www.amazon.co.jp/Flash-Math-Physics-Design-3-0%E3%81%AB%E3%82%88%E3%82%8B%E6%95%B0%E5%AD%A6%E3%83%BB%E7%89%A9%E7%90%86%E5%AD%A6%E8%A1%A8%E7%8F%BE/dp/4797351411
Get Adobe Flash player
by mattodesign 28 May 2009
    Embed
/**
 * Copyright mattodesign ( http://wonderfl.net/user/mattodesign )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6I4n
 */

//練習
//Flash Math & Physics Design:ActionScript 3.0による数学・物理学表現[入門編]
//http://www.amazon.co.jp/Flash-Math-Physics-Design-3-0%E3%81%AB%E3%82%88%E3%82%8B%E6%95%B0%E5%AD%A6%E3%83%BB%E7%89%A9%E7%90%86%E5%AD%A6%E8%A1%A8%E7%8F%BE/dp/4797351411
package 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	
	[SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#000000")]

	public class Yukkuri extends MovieClip {
		//プロパティ宣言
		private var ball:Sprite;
		private var rollovered:Boolean = false;
		private var obj:Array;
		private var timer:Timer;
		
		public function Yukkuri():void {
			ball = new Sprite();
			ball.graphics.beginFill(0xFFFFFF, 0.5);
			ball.graphics.drawCircle(0, 0, 10);
			ball.graphics.endFill();
			ball.x = stage.stageWidth / 2;
			ball.y = stage.stageHeight / 2;
			addChild(ball);
			obj = new Array();
			for (var j:Number = 0; j < 20; j++) {
				var Symbol:Sprite = new Sprite();
				Symbol.graphics.beginFill(Math.random() * 0xFFFFFF, 0.5);
				Symbol.graphics.drawCircle(0, 0, 10);
				Symbol.name = String(obj.length);
				obj.push(Symbol);
			}
			
			for (var i:Number = 0; i < obj.length; i++) {
				obj[i].x = this.stage.stageWidth / 2;
				obj[i].y = this.stage.stageHeight / 2;
				this.addChild(obj[i]);
				}
			
			ball.addEventListener(MouseEvent.ROLL_OVER, onROver);
			ball.addEventListener(MouseEvent.ROLL_OUT, onROut);
			
			timer = new Timer(33);
			timer.addEventListener(TimerEvent.TIMER, loop);
			timer.start();
		}
		
		private function onROver(event:MouseEvent):void {
			rollovered = true;
			}
		
		private function onROut(event:MouseEvent):void {
			rollovered = false;
			}
		
		private function loop(event:TimerEvent):void {
			for (var i:Number = 0; i < obj.length; i++) {
				var koko:Point = new Point();
				var hankei:Number = 200;
				var radian:Number = (Math.PI * 2) / obj.length;
				if (rollovered) {
					setChildIndex(ball, numChildren - 1);
					ball.alpha -= 0.001;
					if (i == 0) {
						koko.x = ball.x ;
						koko.y = ball.y;
					}else {
						koko.x = obj[i - 1].x ;
						koko.y = obj[i - 1].y ;
						}
				}else {
					ball.alpha = 1;
					koko.x = ball.x + hankei * Math.cos(radian * i);
					koko.y = ball.y + hankei * Math.sin(radian * i);
					}
					obj[i].x += (koko.x - obj[i].x) / 3;
					obj[i].y += (koko.y - obj[i].y) / 3;
				}
			}
	}
	
}