Change the Value of the Text Input

We add a function to change the value of the text input.

You can copy this code from this page or download the source file here.

/**
 * Set a text input value
 * @param  id    id attribute of the text input to set the text of
 * @param  text  the text to set
 * @return       true if there was no exception, false otherwise
 */
private function setInputText(id:String, text:String):Boolean {
  var input:TextInput, retval:Boolean = false;  
  try {
    input = TextInput(getElementById(id));
    input.text = text;
    input.dispatchEvent(new Event(flash.events.Event.CHANGE));
    retval = true;
  }
  catch(e:Error) {
  }
  return retval;
}