You'll need to invalidate the component's parent's size and revalidate it before your target's size is computed:
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Script> <![CDATA[ import mx.core.UIComponent; private function clicked():void { trace(bar.width); bar.percentWidth = bar.percentWidth == 100 ? 50 : 100; UIComponent(bar.parent).invalidateSize(); UIComponent(bar.parent).validateNow(); trace(bar.width); } ]]> </mx:Script> <mx:Box id="foo" width="100%" height="50" borderColor="red" borderThickness="1" borderStyle="solid"> <mx:Box id="bar" width="100%" height="100%" borderColor="blue" borderThickness="1" borderStyle="solid" /> </mx:Box> <mx:Button click="clicked()" label="click me" /> </mx:WindowedApplication> Run that and click the button to see the trace output. HTH, Beau On Wed, Aug 26, 2009 at 10:04 AM, jmfillman <[email protected]> wrote: > > > If you trace the width and measuredWidth immediately after setting the > percentWidth, both width and measuredWidth show the original width instead > of the updated width. > > > --- In [email protected] <flexcoders%40yahoogroups.com>, > "valdhor" <valdhorli...@...> wrote: > > > > What does canvas.measuredWidth give when the user clicks the button? > > > > > > --- In [email protected] <flexcoders%40yahoogroups.com>, > "jmfillman" <jmfillman@> wrote: > > > > > > I have a canvas container with="100%". When the user clicks a button, > the container is set to percentWidth=20, and I need to immediately know the > new width so that I can properly re-size elements in the container to match > the new width. > > > > > > From what I can tell, the LayoutManager doesn't get to measuring the > new width of the container right away. If the user clicks the button again, > the LayoutManager has done it's thing and has set the width value of the > canvas. > > > > > > So the question is, how do I get the new width of the canvas as soon as > I set percentWidth=20? > > > > > > > > -- Beau D. Scott Software Engineer

