AS3: Adding styles to a TextArea component using new TextFormat()


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

Confusing but here's the rule. TextFields can use stylesheets. TextArea or TextInput need a new TextFormat()


Copy this code and paste it in your HTML
  1. var textAreaFormat:TextFormat = new TextFormat();
  2. textAreaFormat.size = 30;
  3. textAreaFormat.italic = true;
  4.  
  5. var ta:TextArea = new TextArea();
  6. ta.x = 100;
  7. ta.y = 100;
  8. ta.width = 300;
  9. ta.height = 300;
  10. ta.setStyle("textFormat", textAreaFormat);
  11. ta.htmlText = "This is text within a text area";
  12. addChild(ta);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.