EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Creating a Style Sheet Object

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
424 Working with Text and Strings
Creating a style sheet object
CSSs are represented in ActionScript by the TextField.StyleSheet class. This class is available
only for SWF files that target Flash Player 7 or later. To create a style sheet object, call the
constructor function of the TextField.StyleSheet class:
var newStyle:TextField.StyleSheet = new TextField.StyleSheet();
To add styles to a style sheet object, you can either load an external CSS file into the object or
define the styles in ActionScript. See “Loading external CSS files” on page 424 and “Creating
new styles with ActionScript” on page 426.
You can find a sample source file, formattedText.fla, in the Samples folder on your hard disk,
which shows you how to apply CSS formatting to text that you load into a SWF file
at runtime.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\LoadText.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples and
Tutorials/Samples/ActionScript/LoadText.
Loading external CSS files
You can define styles in an external CSS file and then load that file into a style sheet object.
The styles defined in the CSS file are added to the style sheet object. To load an external CSS
file, you use the
load() method of the TextField.StyleSheet class. To determine when the CSS
file has finished loading, use the style sheet objects
onLoad event handler.
font-family fontFamily A comma-separated list of fonts to use, in
descending order of desirability. Any font family
name can be used. If you specify a generic font
name, it is converted to an appropriate device
font. The following font conversions are available:
mono is converted to _typewriter, sans-serif is
converted to
_sans, and serif is converted to
_serif.
color color Only hexadecimal color values are supported.
Named colors (such as
blue) are not supported.
Colors are written in the following format:
#FF0000.
CSS property ActionScript
property
Usage and supported values

Table of Contents

Related product manuals