example Six, Text enhancements
I. Characteristics involved
In the example, it mainly involves referencing and displaying external CSS files and HTML files in Flash MX 2004. These are the new features that are available in Flash MX 2004 and are very handy to use. The operation of this example in Flash MX 2004 is very simple, but this is a reflection of its powerful features from the side.
Second, the production process
1, the establishment of a file, named Sample.css. Its contents are as follows:
Headline {
Font-family:arial,helvetica,sans-serif;
font-size:16px;
Font-weight:bold;
Display:block;
}
Subheadline {
Font-family:arial,helvetica,sans-serif;
font-size:13px;
Font-weight:bold;
Display:block;
}
mainbody {
Font-family:arial,helvetica,sans-serif;
font-size:10px;
Display:block;
}
Biline {
Font-family:arial,helvetica,sans-serif;
font-size:11px;
Font-style:italic;
Display:inline;
}
A
Font-family:arial,helvetica,sans-serif;
COLOR:CCCCCC;
font-size:10px;
Display:inline;
Text-decoration:underline;
}
In the CSS file above, the corresponding attributes are inside the brackets. For example, Font-family is a character set, Font-size is the font size, display is the way the font is displayed, and so on. As long as there is a simple web-making knowledge should be able to understand.
2, a new file, named Sample.html, its contents are as follows:
Giant Sea Lion spotted
Citizens scared, amazed
Today-our City A giant sea lion is spotted today rampaging around the city ' s main square, scaring thousands of innocent People just out for a daily stroll in the beautiful downtown district.
No injuries were reported after the animal ' two-hour assault of the shopping district-for-it ' s sea famous Lion and Shoes, also known as the "Sea Lion District". Witnesses said the creature came out of the ocean near the Burger King at 42nd and 1st Avenue, startling many and stalling Traffic.
"The animal caused nearly four million dollars of damage to the neighborhood," said Joseph Valente, owner of "sea lions R" Us "at 43rd and 2nd. Onlookers to the scene said, Lion appeared ornery, but otherwise in good spirits.
Officials are uncertain as to, if ever, and the sea lion could return. Click here for more.
The contents of this file are HTML files that have been applied to the CSS format previously created. (Strictly speaking, this file is more like an XML file.) )
3, put a picture named Sample.jpg in the same directory as the file you created in step first to second.
4. Create a new Flash MX 2004 file that is stored in the same directory as the file you created earlier.
5, with the text tool in the scene to pull a text input box, named content. Set the properties panel as shown in 1.
6, create a new layer in timeline, named action, add the following statement to the action panel on this layer:
/* Copyright 2003 Macromedia, Inc. All rights reserved.
The following is Sample Code and are subject to all restrictions
On such code as contained in the end User License agreement
Accompanying this product.
*/
var ss:TextField.StyleSheet = new Textfield.stylesheet (); Note 1
Ss.load ("Sample.css"); NOTE 2
Content.stylesheet = SS; Note 3
Content.multiline= true;
Content.wordwrap = true;
Content.html = true;
Story = new XML (); Note 4
Story.ignorewhite = true;
Story.load ("sample.html"); Note 5
Story.onload = function () {//Note 6
Content.htmltext = story;
}
Note 1: Define a variable SS, which is of type Textfield.stylesheet.
NOTE 2: Reads the contents of the Sample.css file into the SS. Note here that all files are saved in the same path.
Note 3: Set several properties for the content of the text box.
Note 4: Create an XML object.
Note 5: Read the contents of the sample.html file into the story.
Note 6: Set the onload function of the story, the content of the function is the htmltext for story.
Iii. Practical uses
From the example of the production process can be seen, previously in Flash in a row to adjust the text display effect will never appear. Flash MX 2004 Operation HTML file is very flexible, modify the display is also very convenient, as long as the corresponding file to change the content on it. This is useful in using Flash to do more text display processing scenarios.