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

perspective transformation : flash on 2010-2-5

Get Adobe Flash player
by hazel_eyes 13 Feb 2010
    Embed
/**
 * Copyright hazel_eyes ( http://wonderfl.net/user/hazel_eyes )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/h9o5
 */

package {
	import flash.display.Sprite;

	public class Circle extends Sprite {
		private var num:int=10;
		//コンストラクタ
		function Circle() {
			for (var i:int=0; i<num; i++) {
				var myCircle:DrowCircle01 = new DrowCircle01((2*Math.PI/num)*i, num);
				addChild(myCircle);
			}
		}
	}
}
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

class DrowCircle01 extends Sprite {
		private var degree:Number = 0;
		private var radian:Number = 0;
		private var speed:Number = 2;
		private var radLimit:Number = 0;
		private var size:Number = 0;
		private var size1:Number = 0;
		private var ang:Number = 0;
		private var arrayNum:int;
		private var vs:Number = 100;
		private var tmp_x:Number = 0;
		private var tmp_y:Number = 0;
		private var tmp_z:Number = 0;
		private var a:int = 0;


		//コンストラクタ
		public function DrowCircle01(angle:Number,num:int) {
			speed = chgDegree(speed);
			radLimit = chgDegree(360);
			ang = angle;
			arrayNum = num - 1;

			var ball:Sprite = new Sprite;
			ball.graphics.beginFill(Math.random()*0xffffff);
			ball.graphics.drawCircle(0, 0, 17);
			ball.graphics.endFill();
			ball.alpha = 0.9;
			//ball.name = String(a++);
			addChild(ball);
			addEventListener(Event.ENTER_FRAME, frameMove);
		}
		public function frameMove(e:Event):void {
			speed = chgDegree((stage.mouseX - stage.stageWidth/2)/50);
			radian += speed;
			radian %= radLimit;
			tmp_x = Math.cos(radian + ang)*250;
			tmp_y = Math.sin(radian + ang)*20;
			tmp_z = Math.sin(radian + ang)* 50 + 50;

			change3D(tmp_x, tmp_y, tmp_z);

			scaleX = scaleY = size;

			if (Math.sin(radian + ang)>=-0.3) {
				Sprite(root).setChildIndex(this,0);
			} else {
				Sprite(root).setChildIndex(this,arrayNum);
			}

		}
		public function chgDegree(deg:Number):Number {
			var rad:Number;
			rad = deg * Math.PI / 180;
			return rad;
		}
		public function change3D(sx:Number, sy:Number, sz:Number):void {
			x = sx*vs/(vs+sz) + stage.stageWidth/2;
			y = -sy*vs/(vs+sz) + stage.stageHeight/2;
			size = 2*vs/(vs+sz);
		}

	}