Creating new styles with ActionScript

You can create new text styles with ActionScript by using the setStyle() method of the TextField.StyleSheet class. This method takes two parameters: the name of the style and an object that defines that style's properties.

For example, the following code creates a style sheet object named styles that defines two styles that are identical to those you imported earlier (see Loading external CSS files).

var styles = new TextField.StyleSheet();
styles.setStyle("bodyText", 
  {fontFamily: 'Arial,Helvetica,sans-serif', 
  fontSize: '12px'}
);
styles.setStyle("headline", 
  {fontFamily: 'Arial,Helvetica,sans-serif',
  fontSize: '24px'}
);