Posted By

adamcoulombe on 08/13/09


Tagged

actionscript flash TextField styles


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

pauloc


Easy way to Apply Styles to Text fields in Actionscript 2


 / Published in: ActionScript
 

  1. ///////put this somewhere with your other functions//////
  2. TextField.prototype.applyStyles=function(styles){
  3. fmt = new TextFormat();
  4. for (var key:String in styles){
  5. fmt[key]=styles[key];
  6. }
  7. this.setTextFormat(fmt);
  8. }
  9.  
  10.  
  11.  
  12. ////////pass in an object with all the styles you want
  13. myTextField.applyStyles({color:"0xFFFFFF",letterSpacing:-2,bold:true,size:18});
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. /* here's some other styles (flash8)
  23.  
  24. myTextField2.applyStyles({
  25. align:"center",
  26. blockIndent:10, //indents the text block 10pt
  27. bullet:true;
  28. font:"Gill Sans",
  29. indent:"3", //indents first character 3pt
  30. italic:true,
  31. kerning:true, //kerning enabled
  32. leading:15, //15 pixels (line spacing)
  33. leftMargin: 10, //10 point left margin
  34. leftMargin: 10, //10 point right margin
  35. underline:true,
  36. color:"0xFFFFFF",
  37. letterSpacing:-2,
  38. bold:true,
  39. size:18
  40. });
  41.  
  42. */

Report this snippet  

You need to login to post a comment.