         var vsb:ScrollBar = scroller.verticalScrollBar;
         var minViewportInset:Number = scroller.minViewportInset;
         
+        var vsbW:Number = (vsb) ? vsb.getPreferredBoundsWidth() : 0;
+        var hsbH:Number = (hsb) ? hsb.getPreferredBoundsHeight() : 0;
+        var contentW:Number = (viewport) ? viewport.contentWidth : 0;
+        var contentH:Number = (viewport) ? viewport.contentHeight : 0;
+        
         var oldShowHSB:Boolean = hsb && hsb.visible;
         var oldShowVSB:Boolean = vsb && vsb.visible;
         

                if (vsb && viewport)
                { 
                    vAuto = true;
                    var contentHeight:Number = viewport.contentHeight;
                    if (isNaN(explicitViewportH))
                        showVSB = contentHeight > (h - (minViewportInset * 2));
                    else
                        showVSB = contentHeight >  explicitViewportH;
                }                        
                break;
        }
        
        // Shrink the viewport's width,height for the visible scrollbars
        var viewportH:Number = h - minViewportInset;
        var hsbH:Number = 0;
        if (showHSB) 
        {
            hsbH = hsb.getPreferredBoundsHeight();
            viewportH -= Math.max(minViewportInset, hsbH);
        }
        var viewportW:Number = w - minViewportInset;
        var vsbW:Number = 0;
        if (showVSB) 
        {
            vsbW = vsb.getPreferredBoundsWidth();
            viewportW -= Math.max(minViewportInset, vsbW);
        }
        
        // If the scrollBarPolicy is auto, and we're only showing one scrollbar, 
        // the viewport may have shrunk enough to require showing the other one.
        if (showVSB && !showHSB && hAuto && (viewport.contentWidth > viewportW))
        {
            showHSB = true;
            hsbH = hsb.getPreferredBoundsHeight();                
            viewportH -= Math.max(minViewportInset, hsbH);
        }
        else if (!showVSB && showHSB && vAuto && (viewport.contentHeight > viewportH))
        {
            showVSB = true;
            vsbW = vsb.getPreferredBoundsWidth();                
            viewportW -= Math.max(minViewportInset, vsbW);
        }
        
        // Factor in scrollBar-side viewportInsets where there aren't scrollbars
        if (!showHSB)
            viewportH -= minViewportInset;
        if (!showVSB)
            viewportW -= minViewportInset;
            
        // Special case: viewport's size is explicitly set
        if (!isNaN(explicitViewportW))
            viewportW = explicitViewportW;
        if (!isNaN(explicitViewportH))
            viewportH = explicitViewportH;
        
        // layout the viewport
        if (viewport)
        {
            var viewportElt:ILayoutElement = ILayoutElement(viewport);
            viewportElt.setLayoutBoundsSize(viewportW, viewportH);
            viewportElt.setLayoutBoundsPosition(minViewportInset, minViewportInset);
        }
        
        // layout the scrollbars
        if (hsb) hsb.visible = showHSB;
        if (showHSB)
        {
            hsb.setLayoutBoundsSize(Math.max(hsb.getMinBoundsWidth(), w - vsbW), hsbH);
            hsb.setLayoutBoundsPosition(0, h - hsbH);
        }
        if (vsb) vsb.visible = showVSB;
        if (showVSB)
        {
            vsb.setLayoutBoundsSize(vsbW, Math.max(vsb.getMinBoundsHeight(), h - hsbH));
            vsb.setLayoutBoundsPosition(w - vsbW, 0);
        }
        
        // If the scroller's size isn't explicit and we've added a scrollbar, then
        // the measured size is likely to have been wrong.  
        if ((isNaN(target.explicitWidth) || isNaN(target.explicitHeight)) && 
            ((showVSB != oldShowVSB) || (showHSB != oldShowHSB)))
            target.invalidateSize();
             
        target.setContentSize(w, h);
    }

                if (hsb && viewport)
                {
                    hAuto = true;
                    var viewportW:Number = 
                        isNaN(explicitViewportW) ? (w - (minViewportInset * 2)) : explicitViewportW;
                    showHSB = (contentW > viewportW) && (w >= hsb.minWidth);
                } 
                break;
        } 

        var showVSB:Boolean = false;
        var vAuto:Boolean = false;
        switch(scroller.verticalScrollPolicy) {
