Thanks Alex, Makes a lot more sense now.
I have since read more of the documentation and watched a few videos on AdobeTV. As usual a lot of this stuff is already out there. Yet you still find time to answer questions from the community. It is people like you that make this product worth the effort to learn about. Many thanks. --- In [email protected], Alex Harui <aha...@...> wrote: > > If you have a component that extends UIComponent it is responsible for > measuring itself to reserve the right amount of room in the parent container, > and responsible for sizing its children, usually by calling setActualSIze() > and using getExplicitOrMeasuredWIdth/Height > > Alex Harui > Flex SDK Developer > Adobe Systems Inc.<http://www.adobe.com/> > Blog: http://blogs.adobe.com/aharui > > From: [email protected] [mailto:[email protected]] On > Behalf Of neilbrown08 > Sent: Thursday, September 10, 2009 6:27 AM > To: [email protected] > Subject: [flexcoders] Understanding measure process > > > > Hi, > > Searched the forum but cannot find an answer to my problem. Please look at > the code and offer some advice. > > My code is called Highlight.mxml if I put it in a normal VBox container and > call setText it sizes correctly. > > If I create it as a child in my own component which extends UIComponent, I > cannot get it to size at all, its always width = 0 even though I do see > measuredWidth reported correctly. > > I wanted this component to size itself based on what is inside the textfield. > So if it is a child of my component I still would like it to be the size of > the text. > > <?xml version="1.0" encoding="utf-8"?> > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" > creationComplete="creationComplete()" > backgroundColor="0xffffff" > borderColor="0x628297" > borderThickness="1" > borderStyle="solid"> > <mx:Script> > <![CDATA[ > import flash.filters.DropShadowFilter; > > private var str:String; > > private function creationComplete():void > { > this.filters = [new DropShadowFilter(4, 45, 0x333333, 0.5) ]; > } > > override protected function commitProperties():void > { > super.commitProperties(); > > txt.text = this.str; > invalidateSize(); > invalidateDisplayList(); > } > > override protected function measure():void > { > super.measure(); > > measuredWidth = measuredMinWidth = txt.getExplicitOrMeasuredWidth(); > measuredHeight = measuredMinHeight = txt.getExplicitOrMeasuredHeight(); > } > > override protected function updateDisplayList(unscaledWidth:Number, > unscaledHeight:Number):void > { > super.updateDisplayList(unscaledWidth, unscaledHeight); > //this.setActualSize(txt.width, txt.height); > } > > public function setText(str:String):void > { > this.str = str; > invalidateProperties(); > } > > ]]> > </mx:Script> > <mx:Label id="txt" text="100" color="0x000000"/> > </mx:Canvas> >

