Not sure why you're not using Text instead of TextArea.

 

If you don't copy the sizing algorithm of the TextArea's internal
textfield, then your measurments won't be correct.  I don't think -10 is
going to be right and I don't understand 3.9 either.  The code is much
simpler than that.  It uses viewMetrics.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Guillermo Villasana
Sent: Wednesday, September 19, 2007 10:45 AM
To: [email protected]
Subject: [flexcoders] Problem with sizing

 

Hi everyone, well I am still having problems with resizing a Text Area. 
At the moment I am using this code:

package mylib
{
import mx.controls.TextArea;
import flash.text.TextField;
import mx.controls.Alert;
public class AdvancedTextArea extends TextArea
{
public function AdvancedTextArea() {
super();
this.editable=false;
this.selectable=false;
this.verticalScrollPolicy="off";
this.horizontalScrollPolicy="off";

}

override protected function measure():void
{
super.measure();
var myTF:TextField=new TextField();
var altoxLineas:Number=new Number();
myTF.wordWrap=true;
myTF.text=text;
myTF.width=explicitWidth-10;
altoxLineas=myTF.numLines*3.9+altoxLineas/3.9;
measuredHeight = measuredMinHeight = 
myTF.textHeight + 10;
if (altoxLineas>myTF.textHeight) measuredHeight 
= measuredMinHeight = altoxLineas + 10;
}
}
}

Although it does grows my Textarea, in some cases it doesn't grow it 
enough... Any pointers would be appreciated.

 

Reply via email to