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

styles stylesheet


Versions (?)


Who likes this?

5 people have marked this snippet as a favorite

copyleft
jeff
Akuma99
outbox
visuallyspun


AS3: Adding styles to a TextField() using a new StyleSheet() object


Published in: ActionScript 3 


This doesn't show you how to load an external style sheet but it simulates what would happen if the stylesheet.css had already been loaded. Note! There is no simple way of applying a stylesheet to a TextArea component in Flash CS3

  1. var style:StyleSheet = new StyleSheet();
  2. style.parseCSS("h4{color:#ff0000; fontWeight:bold; fontSize:30;}a:link{text-decoration: none;}a:hover{text-decoration: underline;}");
  3. var ti:TextField = new TextField();
  4. ti.x = 150;
  5. ti.y = 150;
  6. ti.width = 100;
  7. ti.height = 100;
  8. ti.styleSheet = style;
  9. ti.htmlText = "<h4>library</h4>";
  10. ti.htmlText += "<p><a href=\"event:http://www.usc.edu\" target=\"_blank\">science</a></p>";
  11. addChild(ti);

Report this snippet 

You need to login to post a comment.