Posted By

chrisaiv on 11/08/07


Tagged

stylesheet styles as3


Versions (?)

Who likes this?

13 people have marked this snippet as a favorite

copyleft
jeff
Akuma99
outbox
visuallyspun
THEPWN3R
peterbelsky
enajenkins
trevorhartman
loric
TrentSkunk
tspitzr
adrianparr


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.