We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

chrisaiv on 11/08/07


Tagged

stylesheet textarea styles TextInput


Versions (?)


Who likes this?

5 people have marked this snippet as a favorite

copyleft
jeff
Akuma99
outbox
visuallyspun


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: 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.

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: grebo on February 22, 2008

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

You need to login to post a comment.