Skip to main content
ramviswa123
Known Participant
September 30, 2013
Question

How to add one symbol in between the user give input.

  • September 30, 2013
  • 1 reply
  • 1290 views

Hi,

     In my flash had the following code.

import flash.events.TextEvent;

tf.addEventListener(TextEvent.TEXT_INPUT, tfHandler);

function tfHandler(e:TextEvent):void{

    trace(e.target.text.length);

    if(e.target.text.length == 2){

        e.target.appendText("-");

        stage.focus = tf;

        tf.setSelection(tf.text.length,tf.text.length);

    }

}

     Like this How to do in AS2.?

Thanks with,

Viswa

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
September 30, 2013

Use:

tf.onChanged = function(){

    if(tf.length == 3){

       tf.text += "-";

       Selection.setSelection(tf.text.length, tf.text.length);

    }

}