If you set verticalScrollPolicy="on" then the scrollbars will be
factored in

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Tuesday, July 22, 2008 10:13 PM
To: [email protected]
Subject: Re: [flexcoders] Measurement and scrolling

 

The only way to not have scrollbars over the content (or to only have
vertical, but not all the time) is to do scrollbar management yourself
rather than relying on Flex's inbuilt methods of handling it. This is a
decision made by the Flex team to avoid having to double measure() stuff
when adding scrollbars to a container.

-Josh

On Wed, Jul 23, 2008 at 3:02 PM, Richard Rodseth <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

Below is code for a scrolling container of one child - a highly
simplified version of the tiling container I've been wrestling with
off and on for way too long now. The component below sizes the
first/only child to fit within it, with some padding, but respects the
minimums of the child, adding scroll bars if necessary.

I discovered this evening that setting measuredMinWidth/Height in the
measure() method was what was messing things up. With that removed,
this component (and the more complex tiler) behaves properly, except
that the scollbars are drawn over the right/bottom padding.

What is the appropriate way to compensate for that? Adding a fudge
factor to the measured values, or removing it from the value passed to
setActualSize in UDL had no effect at all.

Thanks, I'm *really* close now...

- Richard


       public class MyContainer extends Container
       {
               private static const PADDING:Number = 10;

               public function MyContainer()
               {
                       super();
               }


               override protected function measure():void
               {
                       var child:UIComponent = this.getChildren()[0] as
UIComponent;

                       var childWidth:Number =
child.getExplicitOrMeasuredWidth();
                       var childHeight:Number =
child.getExplicitOrMeasuredHeight();

                       measuredWidth = childWidth + 2 * PADDING ;
                       measuredHeight = childHeight + 2 * PADDING ;
               }


               override protected function
updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
               {
               super.updateDisplayList(unscaledWidth, unscaledHeight);

               var child:UIComponent = this.getChildren()[0] as
UIComponent;

                       var newWidth:Number = Math.max(unscaledWidth - (2
* PADDING) ,
child.minWidth);
                       var newHeight:Number = Math.max(unscaledHeight -
(2 * PADDING) ,
child.minHeight);

               child.setActualSize(newWidth, newHeight);
               child.move(PADDING, PADDING);
       }
       }
}

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
       layout="absolute" minHeight="0" minWidth="0"
       verticalScrollPolicy="off" horizontalScrollPolicy="off"
       xmlns:comp="comp.*"
       >

       <comp:MyContainer  width="95%" height="95%" borderStyle="solid"
horizontalScrollPolicy="auto" verticalScrollPolicy="auto">
               <mx:Button label="400x400" minWidth="400"
minHeight="400"/>
       </comp:MyContainer>

</mx:Application>


------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> 
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo
<http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo> ! Groups
Links


   (Yahoo! ID required)

   mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> 






-- 
"Therefore, send not to know For whom the bell tolls. It tolls for
thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  

 

Reply via email to