 		
 		if (rightShadow || topShadow)
 		{
-			var trWidth:Number = Math.min(trRadius + rightThickness + distance,
+			var trWidth:Number = Math.min(trRadius + widthThickness,
 										  maxCornerWidth);
-			var trHeight:Number = Math.min(trRadius + topThickness + distance,
+			var trHeight:Number = Math.min(trRadius + heightThickness,
 										   maxCornerHeight);
 
 			matrix.tx = x + width + rightThickness - shadow.width;

		// Create a Shape containing a round rectangle that the
		// specified corner radii and very short sides.
		var roundRectWidth:Number = Math.max(tlRadius, blRadius) + 
								    2 * distance + 
									Math.max(trRadius, brRadius);
		var roundRectHeight:Number = Math.max(tlRadius, trRadius) +
									 2 * distance +
									 Math.max(blRadius, brRadius);

		if (roundRectWidth < 0 || roundRectHeight < 0)

		// Copy the corners of the shadow bitmap onto the graphics object
		if (leftShadow || topShadow)
		{
			var tlWidth:Number = Math.min(tlRadius + widthThickness,
										  maxCornerWidth);
			var tlHeight:Number = Math.min(tlRadius + heightThickness,
										   maxCornerHeight);

			matrix.tx = x - leftThickness;
