forked from: flash on 2009-7-7

by dizgid forked from flash on 2009-7-7 (diff: 21)
♥0 | Line 33 | Modified 2010-02-12 18:24:15 | MIT License
play

ActionScript3 source code

/**
 * Copyright dizgid ( http://wonderfl.net/user/dizgid )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4mN0
 */

// forked from rooooon's flash on 2009-7-7
package {
	import flash.text.TextField;
	
	import flash.display.Sprite;
	import flash.geom.Matrix3D;
	import flash.events.Event;
	
	
	public class TestMatrix extends Sprite {
		
		private var box:Sprite;
		private var mat:Matrix3D = new Matrix3D();
		
		private var _txt:TextField;
		
		public function TestMatrix() {
			
			_txt = new TextField();
			_txt.width = stage.stageWidth;
			this.addChild(_txt);
			
			box = new Sprite();
			box.graphics.beginFill( 0x00ff00 );
			box.graphics.drawRect( -50, -50, 100, 100 );
			box.graphics.endFill();
			addChild( box );
			
			box.x = stage.stageWidth/2 - 100;
			box.y = stage.stageHeight/2;
			
			//box.transform.matrix3D = mat;
			
			addEventListener( Event.ENTER_FRAME, onEnter );
			
		}
		
		private function onEnter( e:Event ):void {
			/*
			var v:Vector.<Number> = Vector.<Number>([
				1, 0, 0, 0,
				0, 1, 0, 0,
				0, 0, 1, 0,
				stage.stageWidth/2, stage.stageHeight/2, 0, 1
			]);
			
			box.transform.matrix3D.rawData = v;
			*/
			box.rotationX += 0.5;
			//box.rotationZ += 0.5;
			var dat:Vector.<Number> = box.transform.matrix3D.rawData;
			var str:String = String(dat[0]) +"\t"+ String(dat[1]) +"\t"+ String(dat[2]) +"\t"+ String(dat[3]) + "\n";
			str += String(dat[4]) +"\t"+ String(dat[5]) +"\t"+ String(dat[6]) +"\t"+ String(dat[7]) + "\n";
			str += String(dat[8]) +"\t"+ String(dat[9]) +"\t"+ String(dat[10]) +"\t"+ String(dat[11]) + "\n";
			str += String(dat[12]) +"\t"+ String(dat[13]) +"\t"+ String(dat[14]) +"\t"+ String(dat[15]) + "\n";
			_txt.text = str;
		}
	}
}