Yes, it would, and I think I just figured out how to do it...
A few changes and I have come up with this:
public class LimitedTextArea extends TextArea {
private static const MAX_LINES:int = 10;
private var allowMore:Boolean = true;
public function LimitedTextArea(){
addEventListener(flash.events.TextEvent.TEXT_INPUT,textInputHandler );
}
//--------------------------------------------------
// EVENT LISTENERS
//--------------------------------------------------
override protected function keyDownHandler(event:KeyboardEvent):void {
if( textField.numLines == MAX_LINES && event.keyCode == 13 )
allowMore = false;
else {
if( textField.numLines > MAX_LINES )
allowMore = false;
else
allowMore = true;
}
super.keyDownHandler(event);
}
override protected function keyUpHandler(event:KeyboardEvent):void {
if( !allowMore && text.charAt(text.length-1) == '\r' ){
text = text.substr(0,text.length-1);
}
super.keyUpHandler(event);
}
private function textInputHandler( event:TextEvent ):void {
if( !allowMore )
event.preventDefault();
}
//--------------------------------------------------
}
Do you see any problems with this?