      *  The return value is any extra space that's left over
      *  after growing all children to their maxHeight.
      */
-    public function distributeHeight(layoutItemArray:Array,
-                                     width:Number,
-                                     height:Number):Number
+    public function distributeHeight(width:Number, 
+                                     height:Number, 
+                                     restrictedWidth:Number):Number
     {
         var spaceToDistribute:Number = height;
         var totalPercentHeight:Number = 0;
         var childInfoArray:Array = [];
         var childInfo:LayoutItemFlexChildInfo;
         var newWidth:Number;
+        var layoutItem:ILayoutItem;
+        
+        // rowHeight can be expensive to compute
+        var rh:Number = (variableRowHeight) ? 0 : rowHeight;
+        var count:uint = target.numLayoutItems;
+        var totalCount:uint = count; // number of items to use in gap calculation
         
         // If the child is flexible, store information about it in the
         // childInfoArray. For non-flexible children, just set the child's
         // width and height immediately.
-        for each (var layoutItem:ILayoutItem in layoutItemArray)
-        {
-            if (hasPercentHeight(layoutItem))
+        for (var index:int = 0; index < count; index++)
+        {
+            layoutItem = target.getLayoutItemAt(index);
+            if (!layoutItem || !layoutItem.includeInLayout)
+            {
+                totalCount--;
+                continue;
+            }
+            
+            if (hasPercentHeight(layoutItem) && variableRowHeight)
             {
                 totalPercentHeight += layoutItem.percentHeight;
 

                                                                spaceToDistribute,
                                                                totalPercentHeight,
                                                                childInfoArray);
            for each (childInfo in childInfoArray)
            {
            	newWidth = NaN;
            	if (hasPercentWidth(childInfo.layoutItem))
            	   newWidth = calculatePercentWidth(childInfo.layoutItem, width);

                childInfo.layoutItem.setActualSize(newWidth, childInfo.size);
            }
        }
        return spaceToDistribute;

        var maxY:Number = 0;
        var firstRowInView:int = -1;
        var lastRowInView:int = -1;
        
        for (var index:int = 0; index < count; index++)
        {
            layoutItem = layoutTarget.getLayoutItemAt(index);
            if (!layoutItem || !layoutItem.includeInLayout)
                continue;
                
            // Set the layout item's position
            var x:Number = (contentWidth - layoutItem.actualSize.x) * hAlign;
            layoutItem.setActualPosition(x, y);
                
            // Update maxX,Y, first,lastVisibleIndex, and y
            var dx:Number = layoutItem.actualSize.x;
            var dy:Number = layoutItem.actualSize.y;
            maxX = Math.max(maxX, x + dx);
            maxY = Math.max(maxY, y + dy);
