Tuesday, April 14, 2009

Programatically Formatting Text in Actionscript

Create a text format object first and then add it to a text field with "setTextFormat".
var textFormat:TextFormat = new TextFormat();
textFormat.color = 0xFF0000;
textFormat.size = 32;
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT;
textField.wordWrap = true;
textField.text = "The quick brown fox ";
textField.width = 500;
textField.x = 25;
textField.y = 25;
textField.setTextFormat(textFormat);
addChild(textField);

0 comments: