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

扁球面上の点

Get Adobe Flash player
by 178ep3 01 Aug 2009
    Embed
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/plqJ
 */

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	[SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)] 
	public class Sphere extends Sprite
	{
		public function Sphere()
		{
			var i:int = 0;
			var max:uint = 144;
			var list:Array = [];
			for(i=0; i<max; i++)
			{
				var d:Dot = addChild(new Dot(i))as Dot;
				list.push(d);
			}
			
			addEventListener(Event.ENTER_FRAME,upup);
			
			function upup(e:Event):void
			{
				for(i=0; i<max; i++)
				{
					list[i].loop();
				}
			}
		}
	}
}

	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;

class Dot extends Sprite
{
	private var _x:Number=0;
	private var _y:Number=0;
	private var _z:Number=0;
	
	private var _xyAngle:Number = 0;
	private var _xzAngle:Number = 0;
	private var _xyAdd:Number;
	private var _xzAdd:Number;
	
	private var _a:Number = 150;
	private var _b:Number = 75;
	private var _rad:uint=100;
	private var _dot:Shape;
		
	public function Dot(setNum:int)
	{
		_xyAngle = setNum*10;
		_xzAngle = setNum*2.5-90;
		
		this.x = 232;
		this.y = 232;
		
		_xyAdd = 1;
		_xzAdd = 0.7;
		
		init();
	}
		
	private function init():void
	{
		_dot = addChild(new Shape())as Shape;
		with(_dot.graphics)
		{
			beginFill(0xffffff);
			drawCircle(0,0,2);
			endFill();
		}
	}
			
	public function loop():void
	{
		_xyAngle +=_xyAdd;
		_xzAngle +=_xzAdd;
		if(_xyAngle>360)_xyAngle-=360;
		if(_xzAngle>360)_xzAngle-=360;
			
		_x = Math.cos(_xyAngle*Math.PI/180)*_a;
		_y = Math.sin(_xyAngle*Math.PI/180)*_b;
		_x = _x * Math.cos(_xzAngle*Math.PI/180);
		_z = Math.sqrt((Math.pow(_b,2) * (Math.pow(_a,2) - Math.pow(_x,2) - Math.pow(_y,2)))/Math.pow(_a,2));
		if(_xzAngle>180)_z*=-1;
		_dot.x = _x;
		_dot.y = _y;
		_dot.alpha = (_z/75+1);
	}
}