Posted By

adrianparr on 05/11/10


Tagged

format text size font textarea bold as3 component TextFormat italic setstyle


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

tspitzr
tamak


AS3 Format the Text of a TextArea Component


 / Published in: ActionScript 3
 

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

  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  

You need to login to post a comment.