package classes.matuto.utils.display
{
	import flash.display.DisplayObject;

	public class Position
	{
		public static function getPostionStage(obj :DisplayObject, position :Object = null) :Object
		{
			if(obj.stage)
			{
				
				if(!position) {
					position = new Object();
					
					position.x = obj.x;
					position.y = obj.y;
				}
				
				if(!obj.parent) return position;
				else {
					
					position.x += obj.parent.x;
					position.y += obj.parent.y;
					
					if(obj.parent.scrollRect)
					{
						position.x -= obj.parent.scrollRect.x;
						position.y -= obj.parent.scrollRect.y;
					}
					
					return getPostionStage(obj.parent, position);
					
				}
				
			}else return null;
		}
	}
}