             if (!layoutElement || !layoutElement.includeInLayout)
                 continue;
 
-            var hCenter:Number = LayoutElementHelper.parseConstraintValue(layoutElement.horizontalCenter);
-            var vCenter:Number = LayoutElementHelper.parseConstraintValue(layoutElement.verticalCenter);
-            var left:Number    = LayoutElementHelper.parseConstraintValue(layoutElement.left);
-            var right:Number   = LayoutElementHelper.parseConstraintValue(layoutElement.right);
-            var top:Number     = LayoutElementHelper.parseConstraintValue(layoutElement.top);
-            var bottom:Number  = LayoutElementHelper.parseConstraintValue(layoutElement.bottom);
+            var hCenter:Number       = LayoutElementHelper.parseConstraintValue(layoutElement.horizontalCenter);
+            var vCenter:Number       = LayoutElementHelper.parseConstraintValue(layoutElement.verticalCenter);
+            var baseline:Number      = LayoutElementHelper.parseConstraintValue(layoutElement.baseline);
+            var left:Number          = LayoutElementHelper.parseConstraintValue(layoutElement.left);
+            var right:Number         = LayoutElementHelper.parseConstraintValue(layoutElement.right);
+            var top:Number           = LayoutElementHelper.parseConstraintValue(layoutElement.top);
+            var bottom:Number        = LayoutElementHelper.parseConstraintValue(layoutElement.bottom);
+            var percentWidth:Number  = layoutElement.percentWidth;
+            var percentHeight:Number = layoutElement.percentHeight;
+            
             var elementMaxWidth:Number = layoutElement.getMaxBoundsWidth();
             var elementMaxHeight:Number = layoutElement.getMaxBoundsHeight();
-
-            // Remember child position before setting layoutSize, since changing the size may
-            // change the position.
-            var childX:Number = layoutElement.getLayoutBoundsX();
-            var childY:Number = layoutElement.getLayoutBoundsY();
 
             // Calculate size
             var childWidth:Number = NaN;
             var childHeight:Number = NaN;
 
-            if (!isNaN(left) && !isNaN(right))
+            if (!isNaN(percentWidth))
+            {
+                var availableWidth:Number = unscaledWidth;
+                if (!isNaN(left))
+                    availableWidth -= left;
+                if (!isNaN(right))
+                     availableWidth -= right;
+
+                childWidth = availableWidth * Math.min(percentWidth * 0.01, 1);
+                elementMaxWidth = Math.min(elementMaxWidth,
+                    maxSizeToFitIn(unscaledWidth, hCenter, left, right, layoutElement.getLayoutBoundsX()));
+            }
+            else if (!isNaN(left) && !isNaN(right))
             {
                 childWidth = unscaledWidth - right - left;
             }
-            else if (!isNaN(layoutElement.percentWidth))
-            {
-                childWidth = unscaledWidth * Math.min(layoutElement.percentWidth * 0.01, 1);
-                elementMaxWidth = Math.min(elementMaxWidth,
-                    maxSizeToFitIn(unscaledWidth, hCenter, left, right, childX));
-            }
-
-            if (!isNaN(top) && !isNaN(bottom))
+
+            if (!isNaN(percentHeight))
+            {
+                var availableHeight:Number = unscaledHeight;
+                if (!isNaN(top))
+                    availableHeight -= top;
+                if (!isNaN(bottom))
+                    availableHeight -= bottom;    
+                    
+                childHeight = availableHeight * Math.min(percentHeight * 0.01, 1);
+                elementMaxHeight = Math.min(elementMaxHeight,
+                    maxSizeToFitIn(unscaledHeight, vCenter, top, bottom, layoutElement.getLayoutBoundsY()));
+            }
+            else if (!isNaN(top) && !isNaN(bottom))
             {
                 childHeight = unscaledHeight - bottom - top;
-            }
-            else if (!isNaN(layoutElement.percentHeight))
-            {
-                childHeight = unscaledHeight * Math.min(layoutElement.percentHeight * 0.01, 1);
-                elementMaxHeight = Math.min(elementMaxHeight,
-                    maxSizeToFitIn(unscaledHeight, vCenter, top, bottom, childY));
             }
 
             // Apply min and max constraints, make sure min is applied last. In the cases

package spark.layout
{

import flash.geom.Point;
import flash.geom.Rectangle;

import spark.components.supportClasses.GroupBase;
import mx.core.ILayoutElement;
import spark.layout.supportClasses.LayoutBase;
import spark.layout.supportClasses.LayoutElementHelper;


                childX = left;
            else if (!isNaN(right))
                childX = unscaledWidth - elementWidth - right;
            else
                childX = layoutElement.getLayoutBoundsX();

            // Vertical position
            if (!isNaN(vCenter))
                childY = Math.round((unscaledHeight - elementHeight) / 2 + vCenter);
            else if (!isNaN(baseline))
                childY = baseline - IVisualElement(layoutElement).baselinePosition;
            else if (!isNaN(top))
                childY = top;
            else if (!isNaN(bottom))
                childY = unscaledHeight - elementHeight - bottom;
            else
                childY = layoutElement.getLayoutBoundsY();

            // Set position
            layoutElement.setLayoutBoundsPosition(childX, childY);
