                 else
                     layoutElementWidth = layoutElement.getPreferredBoundsWidth();
                 
-                contentWidth = Math.max(contentWidth, layoutElementWidth);
+                containerWidth = Math.max(containerWidth, layoutElementWidth);
             }
         }
 

        if (horizontalAlign == HorizontalAlign.JUSTIFY)
            restrictedWidth = targetWidth;
        else if (horizontalAlign == HorizontalAlign.CONTENT_JUSTIFY)
            restrictedWidth = contentWidth;
    
        distributeHeight(targetWidth, targetHeight, restrictedWidth);
        

                continue;
                
            // Set the layout element's position
            var x:Number = (containerWidth - layoutElement.getLayoutBoundsWidth()) * hAlign;
            layoutElement.setLayoutBoundsPosition(x, y);
                            
            // Update maxX,Y, first,lastVisibleIndex, and y
