 
 import mx.core.IFlexDisplayObject;
 import mx.core.IFactory;
+
+import flash.geom.Rectangle;
+import mx.utils.MatrixUtil;
 
 use namespace mx_internal;
 

		
		var m:Matrix = $transform.concatenatedMatrix;
		
		var registrationPoint:Point = new Point();
		var popUpWidth:Number = autoSizePopUpWidth ? unscaledWidth : popUp.getPreferredBoundsWidth(false);
		var popUpHeight:Number = autoSizePopUpHeight ? unscaledHeight : popUp.getPreferredBoundsHeight(false);
		
		determinePosition(popUpPosition,popUpWidth,popUpHeight,registrationPoint);
		var globalTL:Point = m.transformPoint(registrationPoint);
		registrationPoint.x += popUpWidth;
		registrationPoint.y += popUpHeight;
		var globalBR:Point = m.transformPoint(registrationPoint);
		var adjustedPlacement:String;
		
		if (screen)
		{
			switch(popUpPosition)
			{
				case "below":
					if(globalBR.y > screen.bottom)
						adjustedPlacement = "above"; 
					break;
				case "above":
					if(globalTL.y < screen.top)
						adjustedPlacement = "below"; 
					break;
				case "left":
					if(globalBR.x < screen.left)
						adjustedPlacement = "right"; 
					break;
				case "right":
					if(globalTL.y > screen.right)
						adjustedPlacement = "left"; 
					break;
			}
		}
		
		if(adjustedPlacement != null)
		{
			determinePosition(adjustedPlacement,popUpWidth,popUpHeight,registrationPoint);
			globalTL = m.transformPoint(registrationPoint);
		}
		
		// Set the dimensions explicitly because UIComponents always set themselves to their
		// measured / explicit dimensions if they are parented by the SystemManager.  
		popUp.width = popUpWidth;
		popUp.height = popUpHeight;
		
		// Position the popUp. 
		m.tx = globalTL.x;
		m.ty = globalTL.y;
		popUp.setLayoutMatrix(m,false);
	}
	

	private var popUpIsDisplayed:Boolean = false;
	private var addedToStage:Boolean = false;
	
	private static var decomposition:Vector.<Number> = new Vector.<Number>();
	decomposition.push(0);
	decomposition.push(0);
	decomposition.push(0);
	decomposition.push(0);
	decomposition.push(0);	
	
	//--------------------------------------------------------------------------
    //
    //  Properties
