package net.fdms.Function.Convert 
{
	import flash.display.DisplayObject;
	import flash.display.Stage;
	import net.fdms.Frame.Frame;
	import flash.geom.Point;
	/**
	 * ...
	 * @author ...
	 */
	public class StringToPoint 
	{
		
		public function StringToPoint() 
		{
			
		}
		
		public static function getPoint(target:DisplayObject, pointStr:String = "Center", reset:Array = null):Point {
			var tX:Number, tY:Number;
			var rX:Number = (reset != null)?reset[0]:0;
			var rY:Number = (reset != null)?reset[1]:0;
			var rWidth:Number = (reset != null && reset[2] != 0)?reset[2]:target.width;
			var rHeight:Number = (reset != null && reset[3] != 0)?reset[3]:target.height;
			var Refer:* = Frame.Stage;
			switch(pointStr) {
				case "LC":
					tX = rX;
					tY = (Refer.stageHeight - rHeight) / 2 + rY;
					break;
				case "LB":
					tX = rX;
					tY = Refer.stageHeight - rHeight - rY;
					break;
				case "CT":
					tX = (Refer.stageWidth - rWidth) / 2 + rX;
					tY = rY;
					break;
				case "Center":
					tX = (Refer.stageWidth - rWidth) / 2 + rX;
					tY = (Refer.stageHeight - rHeight) / 2 + rY;
					break;
				case "CB":
					tX = (Refer.stageWidth - rWidth) / 2 + rX;
					tY = Refer.stageHeight - rHeight - rY;
					
					break;
				case "RT":
					tX = Refer.stageWidth - rWidth - rX;
					tY = rY;
					break;
				case "RC":
					tX = Refer.stageWidth - rWidth - rX;
					tY = (Refer.stageHeight - rHeight) / 2 + rY;
					break;
				case "RB":
					tX = Refer.stageWidth - rWidth - rX;
					tY = Refer.stageHeight - rHeight - rY;
					break;
				default:
					tX = rX;
					tY = rY;
					break;
			}
			return new Point(tX, tY);
		}
		
	}

}