Limit the number of lines in an input textfield


/ Published in: ActionScript 3
Save to your folder(s)

I made one adjustment to the code because I was getting one scrolling extra line.

inputfield.textHeight > inputfield.height
to:

inputfield.textHeight >= inputfield.height


Copy this code and paste it in your HTML
  1. var prevText:String;
  2. inputfield.addEventListener(Event.CHANGE, onUpdate);
  3.  
  4. private function onUpdate(e:Event):void {
  5. if (inputfield.textHeight >= inputfield.height){
  6. inputfield.text = prevText;
  7. }else prevText= inputfield.text;
  8. }

URL: http://blog.designreact.co.uk/2010/06/as3-limit-the-number-of-lines-in-an-input-textfield/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.