flash on 2009-12-31

by nemu90kWw
♥0 | Line 41 | Modified 2009-12-31 08:39:21 | MIT License
play

ActionScript3 source code

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

package
{
	import flash.display.*;
	import flash.geom.*;
	import flash.events.*;
	import flash.text.*;
	
	[SWF(width="465", height="465", frameRate="60")]
	public class FlashTest extends Sprite
	{
		private var textfield:TextField = new TextField();
		
		function FlashTest()
		{
			textfield.width = textfield.height = 465;
			addChild(textfield);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
		
		private function onMouseMove(e:MouseEvent):void
		{
			var matrix:Matrix;
			var x:int, y:int;
			var pos:Point;
			
			matrix = new Matrix(mouseX, mouseY);
			textfield.text = matrix + "\n";
			matrix.rotate(Math.PI/2);
			x = Math.round(mouseX*Math.cos(Math.PI/2)+mouseY*Math.sin(Math.PI/2));
			y = Math.round(mouseY*Math.cos(Math.PI/2)+mouseX*Math.sin(Math.PI/2));
			matrix.a = Math.round(Math.abs(matrix.a));
			matrix.b = Math.round(Math.abs(matrix.b));
			textfield.text += matrix + "\n";
			textfield.text += x + ", " + y + "\n\n";
			
			matrix = new Matrix();
			matrix.translate((-100+1)/2, (-200+1)/2);
			matrix.rotate(Math.PI/2);
			matrix.translate((200-1)/2, (100-1)/2);
			pos = matrix.transformPoint(new Point(mouseX, mouseY));
			textfield.text += matrix + "\n";
			textfield.text += pos + "\n";
			textfield.text += Math.round(pos.x) + ", " + Math.round(pos.y) + "\n\n";
		}
	}
}