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

私はクルマ。タイヤはまだない

パネルのZソートもない
* 法線(光沢)もない
* タイヤがないから走れない
* マウスに反応もしない
* ただクルクル回るだけ
Get Adobe Flash player
by Kay 18 Mar 2009
/*
 * パネルのZソートもない
 * 法線(光沢)もない
 * タイヤがないから走れない
 * マウスに反応もしない
 * ただクルクル回るだけ
 */
package {
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	[SWF(width=400,height=400)]
	public class Take03 extends Sprite {
		public var cars:Array = new Array();
		private var axis_array:Array = new Array(Vector3D.X_AXIS, Vector3D.Y_AXIS, Vector3D.Z_AXIS);
		public function Take03():void {
			for (var d:uint = 0; d < 3; d++) {
				for (var h:uint = 0; h < 3; h++) {
					for (var v:uint = 0; v < 3; v++) {
						var car:Car = new Car(Math.floor(Math.random()*0xffffff));
						car.x = 300*h-100;
						car.y = 300*v-100;
						car.z = 300*(3-d)+200;
						car.axis = axis_array[Math.floor(Math.random()*3)];
						car.nRotation = Math.random()*3-6;
						car.mtx.appendRotation(Math.random()*49-90,axis_array[Math.floor(Math.random()*3)]);
						car.mtx.appendScale(3,3,3);
						car.render();
						car.addEventListener(Event.ENTER_FRAME, xRotate);
						addChild(car);
					}
				}
			}
		}
		private function xRotate(e:Event):void {
			var nR:Number = e.target.nRotation;
			var axis:Vector3D = e.target.axis;
			e.target.mtx.appendRotation(nR,axis);
			e.target.render();
		}
	}
}
import flash.display.*;
import flash.geom.*;
class Car extends Sprite {
	public var vertices:Vector.<Number> = new Vector.<Number>();
	private var uvt:Vector.<Number> = new Vector.<Number>();
	private var panelInfo:Vector.<Number> = new Vector.<Number>();
	private var faces:Vector.<Sprite> = new Vector.<Sprite>();
	public var mtx:Matrix3D = new Matrix3D();
	public var myColor:uint;
	public var axis:Vector3D = new Vector3D();
	public var nRotation:Number;
	public function Car(color:uint):void {
		myColor = color;
		setApexes();
	}
	public function setApexes():void {
		// 側面を描く頂点を取得
		vertices.push(-22,   2, -15,// 0
				   -22, -4, -10,	// 1
				   -10, -8, -12,	// 2
				     0, -20,  -10,	// 3
				    12, -20,  -10,	// 4
				    18, -10, -15,	// 5
				    26, -10, -13,	// 6
				    28,   2, -15,	// 7
				    14, 2, -15,		// 8
				   -10, 2, -15);	// 9
		// 反対側のポイントを作成
		var verticesNum:uint = vertices.length;
		for (var i:uint = 0; i < verticesNum; i++) {
			if (i % 3 == 2) {
				vertices.push(vertices[i]*-1);	// z値を反転
			} else {
				vertices.push(vertices[i]);
			}
		}
		// Panel情報(verticIndices, color, alpha)
		var offset:uint = vertices.length/3/2;
		panelInfo.push(3,4,2,5,                            0x66cccc,1);	// Left
		panelInfo.push(4+offset,3+offset,5+offset,2+offset,0x66cccc,1);	// Right
		panelInfo.push(3+offset,3,2+offset,2,              0x66cccc,1);	// Front
		panelInfo.push(4,4+offset,5,5+offset,              0x66cccc,1);	// Rear
		panelInfo.push(1+offset,1,0+offset,0,              myColor,1);
		panelInfo.push(2+offset,2,1+offset,1,              myColor,1);
		panelInfo.push(4+offset,4,3+offset,3,              myColor,1);
		panelInfo.push(6+offset,6,5+offset,5,              myColor,1);
		panelInfo.push(7+offset,7,6+offset,6,              myColor,1);
		panelInfo.push(1,2,0,9,                            myColor,1);
		panelInfo.push(2,5,9,8,                            myColor,1);
		panelInfo.push(5,6,8,7,                            myColor,1);
		panelInfo.push(2+offset,1+offset,9+offset,0+offset,myColor,1);
		panelInfo.push(5+offset,2+offset,8+offset,9+offset,myColor,1);
		panelInfo.push(6+offset,5+offset,7+offset,8+offset,myColor,1);
		panelInfo.push(7,7+offset,8,8+offset,0x666666,1);
		panelInfo.push(8,8+offset,9,9+offset,0x666666,1);
		panelInfo.push(9,9+offset,0,0+offset,0x666666,1);
	}
	public function render():void {
		var vout:Vector.<Number> = new Vector.<Number>();
		Utils3D.projectVectors(mtx,vertices,vout,uvt);
		graphics.clear();
		var numsPanel:uint = panelInfo.length/6; 
		for (var i:uint = 0; i < numsPanel; i++) {
			var indices:Vector.<int> = new Vector.<int>();
			var ioff:uint = i*6;
			indices.push(panelInfo[ioff+1],panelInfo[ioff+0],panelInfo[ioff+3]);
			indices.push(panelInfo[ioff+2],panelInfo[ioff+3],panelInfo[ioff+0]);
			graphics.beginFill(panelInfo[ioff+4],panelInfo[ioff+5]);
			graphics.drawTriangles(vout,indices,null,TriangleCulling.POSITIVE);
			graphics.endFill();
		}
	}
}