434
Working with Text and Strings
An example of using styles with XML
In this section, you create a FLA file that has XML-formatted text. You’ll create a style sheet
using ActionScript, rather than importing styles from a CSS file as shown in
“An example of
using styles with HTML” on page 431
To format XML with a style sheet:
1.
In Flash, create a FLA file.
2.
Using the Text tool, create a text field approximately 400 pixels wide and 300 pixels high.
3.
Open the Property inspector (Window > Properties > Properties), and select the text field.
4.
In the Property inspector, select Dynamic Text from the Text Type menu, select Multiline
from the Line Type menu, select the Render Text as HTML option, and type
news_txt
in
the Instance Name text box.
5.
On Layer 1 in the Timeline (Window > Timeline), select the first frame.
6.
To create the style sheet object, open the Actions panel (Window > Actions), and add the
following code to the Actions panel:
var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.setStyle("mainBody", {
color:'#000000',
fontFamily:'Arial,Helvetica,sans-serif',
fontSize:'12',
display:'block'
});
styles.setStyle("title", {
color:'#000000',
fontFamily:'Arial,Helvetica,sans-serif',
fontSize:'18',
display:'block',
fontWeight:'bold'
});
styles.setStyle("byline", {
color:'#666600',
fontWeight:'bold',
fontStyle:'italic',
display:'inline'
});
styles.setStyle("a:link", {
color:'#FF0000'
});
styles.setStyle("a:hover", {
textDecoration:'underline'
});
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...