View comments | RSS feed

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 the ones you already imported (see Loading external CSS files):

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

Flash CS3


Comments


turbidity said on Mar 5, 2008 at 10:47 AM :
You need to put periods in front of the style names when they are not HTML tags. This example is wrong.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000911.html