I think you should be using the textInput event, which lets you intercept the 
text before it goes in.

Gordon Smith
Adobe Flex SDK Team

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
tchredeemed
Sent: Friday, November 07, 2008 7:57 AM
To: [email protected]
Subject: [flexcoders] textArea's that are limited by the amount of lines


Basically, I created a custom component that extends TextArea, and I
created a getter that returns the super.textField.

Right now, I am doing this:

private var savedText:String;
private var limitHit:Boolean = false;

keyDown(){
savedText = textArea.text;
var tf:TextField = TextField( (event.currentTarget as
LimitedTextInput).textField );
if( tf.numLines > 14 )
limitHit = true;
}

keyUp(){
if( limitHit ){
textArea.text = savedText;
limitHit = false;
}
}

change(){
if( limitHit ){
textArea.text = savedText;
limitHit = false;
}
}

the problem is, if I hit the limit, I cannot go back and edit the
text, because limitHit is true and I need to know how to say "If it is
deleting or changing text that can fit, allow it"

Am I even doing this the correct way?

Reply via email to