Create a CSS StyleSheet and apply it to a text field, sample code.

The code below will create a StyleSheet instance and apply that to any instance on the stage you specify, in this example I apply it to a text field instance named my_text_field

———– code sample

var styles:StyleSheet = new StyleSheet();

// setStyle(styleName, styleObject);
// this example sets the paragraph tag
styles.setStyle(“p”, {color:”#CCCC00″});

// Remember to assign the text field the StyleSheet
my_text_field.styleSheet = styles;

———– end code sample

Coming next I will show you my preferred ways of doing things, which is to use an external StyleSheet to keep it easy to change without republishing the flash files, and also keeps the code broken down into logical files.

Published by Peter Witham

Web applications developer & designer. Certified Flash Designer.

Leave a comment