Posted By

christowiz on 04/18/11


Tagged

input lines limit TextField


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Josueriv


Limit the number of lines in an input textfield


 / Published in: ActionScript 3
 

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

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

inputfield.textHeight > inputfield.height

to:

inputfield.textHeight >= inputfield.height
  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. }

Report this snippet  

You need to login to post a comment.