measureText doesn't know how to wordwrap.
I would try: set the .text on the textField, set the textField's width to explicitWidth-10, and return the textHeight + 10 as the measuredHeight ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Guillermo Villasana Sent: Tuesday, September 11, 2007 6:50 AM To: [email protected] Subject: [flexcoders] How to make TextArea resize to fit content Hello, I have been searching around to find out how to make htmlText (or Text if is used instead of htmlText) in TextArea to resize in height so that it won't make a scroll. This is what I was able to understand to achive the problem and generated this class: <code> package myclases { import mx.controls.TextArea; import flash.text.TextLineMetrics; public class AdvancedTextArea extends TextArea { public function AdvancedTextArea() { super(); } // The default size is the size of the text plus a 10 pixel margin. override protected function measure():void { super.measure(); // Calculate the default size of the control based on the // contents of the TextArea.text property. var lineMetrics:TextLineMetrics = measureText(text); // Add a 10 pixel border area around the text. measuredHeight = measuredMinHeight = lineMetrics.height + 10; } } } </code> then I use it in an action script like this: <code> pTextArea=new AdvancedTextArea(); pTextArea.invalidateSize(); pTextArea.width=300; pTextArea.text="a very very long text that should wrap around in a 300px width Text Area. This text is dynamic....;" myCanvas.addChild(pTextArea); </code> Still the TextArea will not resize it's height and the scrollbar appears, what am I doing wrong? How can I resize the pTextArea after the Text or htmlText property is set? Thanks for any help Terius

