See this thread:
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mark
Sent: Tuesday, September 11, 2007 10:34 AM
To: [email protected]
Subject: [flexcoders] dynamic textArea sizing
Is there a way for the textArea to size its Height to fit the text, as
apposed to setting a height in pixels? I don't want the scroll bars
and it's no good for printing.
Any examples out there?
Thanks,
Mark
--- Begin Message ---
Using the Textfield made the trick I also set to off the scroll policies
so they wouldn't show
Thanks
Terius
Alex Harui wrote:
>
> 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
>
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--- End Message ---