Posted By

chrisaiv on 11/08/07


Tagged

stylesheet textarea styles as3 TextInput


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

copyleft
jeff
Akuma99
outbox
visuallyspun
THEPWN3R
enajenkins
loric
TrentSkunk
tspitzr
adrianparr


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


 / Published in: ActionScript 3
 

So from what I can tell, you can't style a TextArea or a TextInput component using a new StyleSheet(). Instead you need to use a new TextFormat().

  1. var tf:TextFormat = new TextFormat();
  2. tf.size = 25;
  3. tf.color = "#FEFEFE";
  4. var ti:TextInput = new TextInput();
  5. ti.x = 100;
  6. ti.y = 100;
  7. ti.width = 200;
  8. ti.height = 30;
  9. ti.htmlText = "<p>Snippler Rocks!</p>";
  10. ti.setStyle("textFormat", tf);
  11. addChild(ti);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: grebo on February 22, 2008

Error in line 3. Should be: tf.color = "0xFEFEFE";

Posted By: drommels on July 8, 2008

while trying to find a solution I stumbled on your post. This was not satisfying enough for me so we wrote a new solution overcoming the problem of not being able to load a stylesheet. see: http://www.sharedknowhow.com/2008/07/fixed-flash-textarea-css-incompatibility/

Posted By: chrisaiv on July 14, 2008

drommels: Thank you for both your contribution and explanation: it's simple, elegant, and extremely handy. I actually can't believe Adobe didn't bother to make TextArea work with StyleSheet, maybe it was an oversight. Regardless, I look forward to seeing many more of your contributions.

You need to login to post a comment.