Using styles with the TextInput

The TextInput component's styles specify values for its skins, padding, and text formatting when the component is drawn. The texFormat and disabledTextFormat styles govern the style of the text that displays in the component. For more information about the skin style properties, see Using skins with the TextInput.

The following example sets the textFormat style to set the font, size, and color of the text that displays in the TextInput component. The same process applies to setting the disabledTextFormat style that is applied when the component is disabled.

To set the textFormat style for a TextInput instance:

  1. Create a new Flash file.
  2. Drag a TextInput component to the Stage and give it an instance name of myTi.
  3. Add the following code to the Actions panel on Frame 1 of the main Timeline.
    var tf:TextFormat = new TextFormat();
    tf.color = 0x0000FF;
    tf.font = "Verdana";
    tf.size = 30;
    tf.align = "center";
    tf.italic = true;
    myTi.setStyle("textFormat", tf);
    myTi.text = "Enter your text here";
    myTi.setSize(350, 50);
    myTi.move(100, 50);
    
  4. Select Control > Test Movie.