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

雪の夜空を見上げる

Vector.forEach()とVector3D.scaleBy()でシミュレート
Get Adobe Flash player
by Kay 28 Feb 2009
    Embed
// Vector.forEach()とVector3D.scaleBy()でシミュレート
package {

	import flash.display.Sprite;
	import flash.geom.Vector3D;
	import flash.events.Event;

	[SWF(width=400, height=400, backgroundColor=0x000000, frameRate=24)]
	public class Take04 extends Sprite {

		private const SW:uint = stage.stageWidth;
		private const SH:uint = stage.stageHeight;
		private var myVector:Vector.<Vector3D> = new Vector.<Vector3D>;
		private var _stage:Sprite;

		public function Take04():void {
			_stage = new Sprite();
			_stage.x = SW/2;
			_stage.y = SW/2;
			addChild(_stage);
			for (var i:uint = 0; i < 2000; i++) { 	
				myVector.push(new Vector3D(
					Math.random()*SW-SW/2,
					Math.random()*SH-SH/2,
					0,
					Math.random()/2));
			}
			addEventListener(Event.ENTER_FRAME, moveObjects);
		}

		private function moveObjects(eventObject:Event):void {
			_stage.graphics.clear();
			myVector.forEach(render);
		}

		private function render(item:Vector3D, index:int, vector:Vector.<Vector3D>):void {
			_stage.graphics.beginFill(0xddffff);
			_stage.graphics.drawCircle(item.x,item.y,item.w);
			_stage.graphics.endFill();

			vector[index].scaleBy(1.03);
			vector[index].x -= Math.sin(item.w);
			vector[index].y -= Math.cos(item.w);
			vector[index].w *= 1.025;
	
			if (Math.abs(vector[index].x) > SW/2 || Math.abs(vector[index].y) > SH/2 || vector[index].w > 30) {
				vector[index].x = Math.random()*SW-SW/2;
				vector[index].y = Math.random()*SH-SH/2;
				vector[index].w = Math.sqrt(Math.random())/2;
			}
		}
	}
}