AS3 Format the Text of a TextArea Component


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

To style the text in a TextArea component, create a TextFormat object and pass it to the TextArea's setStyle method.


Copy this code and paste it in your HTML
  1. import flash.text.TextFormat;
  2. import fl.controls.TextArea;
  3. import fl.managers.StyleManager;
  4.  
  5. var myTextArea:TextArea = new TextArea();
  6. myTextArea.setSize(200, 100);
  7. myTextArea.text = "Hello World";
  8.  
  9. var myTextFormat:TextFormat = new TextFormat();
  10. myTextFormat.font = "Arial";
  11. myTextFormat.size = 18;
  12. myTextFormat.bold = true;
  13. myTextFormat.italic = true;
  14. myTextFormat.underline = true;
  15. myTextArea.setStyle("textFormat", myTextFormat);
  16.  
  17. myTextArea.x = 30;
  18. myTextArea.y = 30;
  19. addChild(myTextArea);
  20.  
  21. // To set ALL TextAreas to this style use ...
  22. // StyleManager.setComponentStyle(TextArea, "textFormat", myTextFormat);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.