Skip to main content
Participant
October 3, 2011
Answered

How can I limit the number of rows of a field Imput Text?

  • October 3, 2011
  • 1 reply
  • 542 views

I do not want to have it scroll. For example if the field has four lines and the user is writing the fourth line, and give such ENTER or continue typing until no longer fit on this line, I do not want to be created in the fifth line text field. It has to do it?

This topic has been closed for replies.
Correct answer Ned Murphy

Here's one approach to limiting the number of lines, someone else might have a different approach... ' tf ' is the instance name of the textfield.

tf.addEventListener(Event.CHANGE, checkNumLines);

function checkNumLines(evt:Event):void {
   if(tf.numLines > 4){ // remove that last charcter typed
       tf.text = String(tf.text).slice(0,tf.length-1);
   }
}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
October 3, 2011

Here's one approach to limiting the number of lines, someone else might have a different approach... ' tf ' is the instance name of the textfield.

tf.addEventListener(Event.CHANGE, checkNumLines);

function checkNumLines(evt:Event):void {
   if(tf.numLines > 4){ // remove that last charcter typed
       tf.text = String(tf.text).slice(0,tf.length-1);
   }
}

October 4, 2011

Thank Youuuuuuuuuuu.

Ned Murphy
Legend
October 4, 2011

You're welcome