Text and Field Formatting


/ Published in: ActionScript 3
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. var format:TextFormat = new TextFormat();
  2. format.bold = true;
  3. format.italic = true;
  4. format.underline = true;
  5. format.font = "Arial";
  6. format.size = 14;
  7. format.color = 0xFFFFFF;
  8. format.align = TextFormatAlign.CENTER;
  9. format.indent = 0;
  10. format.kerning = false;
  11.  
  12. var myTextField = new TextField();
  13. myTextField.embedFonts = true;
  14. myTextField.wordWrap = true;
  15. myTextField.selectable = false;
  16. myTextField.autoSize = TextFieldAutoSize.CENTER;
  17. myTextField.antiAliasType = "advanced";
  18. myTextField.width = 187;
  19. myTextField.x = 256;
  20. myTextField.y = 265;
  21.  
  22. myTextField.setTextFormat(format); //OR
  23. myTextField.defaultTextFormat = format;
  24.  
  25. myTextField.htmlText = "Whatever the text is thats going into the textfield";
  26.  
  27. myTextField.border = true;
  28. myTextField.borderColor = 0xFFFFFF
  29.  
  30. addChild(myTextField);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.