EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 426

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...
426 Working with Text and Strings
As with all other ActionScript methods that load data over the network, the CSS file must
reside in the same domain as the SWF file that is loading the file. (See “Cross-domain and
subdomain access between SWF files” on page 696.) For more information on using CSS
with Flash, see StyleSheet (TextField.StyleSheet) in the ActionScript 2.0 Language
Reference.
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.
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
on page 424):
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'}
);

Table of Contents

Related product manuals