/ Published in: ActionScript 3
myTextField.defaultTextFormat = format; myTextField.setTextFormat(format); Both can be used. The difference is, setTextFormat will only change the text currently in the text field. Any new text inserted into the text field will revert back to its default. defaultTextFormat changes the default which will change the format for the current text and all future text.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var format:TextFormat = new TextFormat(); format.bold = true; format.italic = true; format.underline = true; format.font = "Arial"; format.size = 14; format.color = 0xFFFFFF; format.align = TextFormatAlign.CENTER; format.indent = 0; format.kerning = false; var myTextField = new TextField(); myTextField.embedFonts = true; myTextField.wordWrap = true; myTextField.selectable = false; myTextField.autoSize = TextFieldAutoSize.CENTER; myTextField.antiAliasType = "advanced"; myTextField.width = 187; myTextField.x = 256; myTextField.y = 265; myTextField.setTextFormat(format); //OR myTextField.defaultTextFormat = format; myTextField.htmlText = "Whatever the text is thats going into the textfield"; myTextField.border = true; myTextField.borderColor = 0xFFFFFF addChild(myTextField);