If you were using a TextField you could use the numLines property like this:


 

var lineLimit:uint = 5; // however many lines 

private function txtChangeHandler(event:Event):void
{
            var txt:TextField = TextField(event.currentTarget);
            if (txt.numLines > lineLimit)
            {
                        txt.text = storedInput;
                        // Play an error sound such as ding.wav?
            }else{
                        storedInput = txt.text;
            }
}

 

Alex Harui suggested 'accessing the TextArea's textField property and using
the TextField API' on another thread a while back, but 

the Flex docs say that the TextArea textField property is protected, and he
didn't mention how to get around that, so you would have to override
somehow. 

Regards, 

-Keith 
http://keithreinfeld.home.comcast.net
<http://keithreinfeld.home.comcast.net/> 
 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of tchredeemed
Sent: Thursday, November 06, 2008 10:04 AM
To: [email protected]
Subject: [flexcoders] Limit characters by size, not by maxChars.

 

Anyone come up with a good way to do this?

If I have a textArea that I want to limit the amount you can type in
it by the amount of lines (for print reasons), how could I do it?

I cannot do maxChars, because obviously, maxChars could potentially be
off, if a lot of W's are used!

 

Reply via email to