For mx:Label, you can try using measureText() on the parent unless the label will have different styles that will affect measurement. Then you’ll have to add it and call validateNow() and call getExplicitOrMeasuredWidth().
But why not use mx:Text? Why do you have to get the width exactly? If you stretch an mx:Text to the width of the Vbox it sounds like it would suit your needs. On 8/29/10 2:06 PM, "Laurence" <[email protected]> wrote: Using ActionScript, I want to add a Label to a VBox. I know what text I want to put into the label (said text is read from an XML file), but of course, the program cannot know what the width of the label should be until after the text is read from that XML file. I want the label to be as wide as it needs to be, but not wider than the vBox I'm adding it to -- if that label will need to be wider than the given amount to display all the text, then I want to add a TextArea (with word-wrap turned on) so I can display all the text in that given width. My question is, how do I calculate the width of a label I'll need, when given a string of text? I do know the font-family and font-size the label will have. Is there an easy way to go from a string of text to the width that a label will need to be to display that text? Thanks, Laurence MacNeill Mableton, Georgia, USA -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui

