Thursday, April 22, 2010

set a custom text format on a Flash ActionScript 3.0 TextInput

The following example shows how you can set a custom text format on a Flash ActionScript 3.0 TextInput component by setting the textFormat style to a TextFormat object.

Full code after the jump.

// ActionScript 3.0
/* Requires:
* - TextInput component in Flash library
*/
import fl.controls.TextInput;

var textFmt:TextFormat = new TextFormat();
textFmt.color = 0xFF0000;
textFmt.font = "Courier New"
textFmt.size = 18;

var textInput:TextInput = new TextInput();
textInput.text = new Date().toString();
textInput.setStyle("textFormat", textFmt);
textInput.width = 300;
textInput.move(10, 10);
addChild(textInput);

No comments:

Post a Comment