Formatting Text With Cascading Style Sheets - MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

Getting text metric information
You can use the
for a text string with specific formatting applied. For example, suppose you need to create, at
runtime, a new TextField object containing an arbitrary amount of text that is formatted with a
24-point, bold, Arial font, and a 5-pixel indent. You need to determine how wide or high the new
TextField object must be to display all of the text. The
measurements such as ascent, descent, width, and height.
For more information, see

Formatting text with Cascading Style Sheets

Cascading Style Sheets are a mechanism for creating text styles that can be applied to HTML or
XML documents. A style sheet is a collection of formatting rules that specify how to format
HTML or XML elements. Each rule associates a style name, or selector, with one or more style
properties and their values. For example, the following style defines a selector named
bodyText { text-align: left}
You can create styles that redefine built-in HTML formatting tags used by Flash Player (such as
and
), create style "classes" that can be applied to specific HTML elements using the
<p>
<li>
or
tag's
<span>
class
You use the TextField.StyleSheet class to work with text style sheets. You can load styles from an
external CSS file or create them natively using ActionScript. To apply a style sheet to a text field
that contains HTML- or XML-formatted text, you use the
The styles defined in the style sheet are mapped automatically to the tags defined in the HTML
or XML document.
Using styles sheets involves three basic steps:
Create a style sheet object from the TextField.StyleSheet class. See
object" on page
Add styles to the style sheet object, either by importing them from an external CSS file or by
defining them with ActionScript. See
new styles with ActionScript" on page
Assign the style sheet object to a text field that contains XML- or HTML-formatted text. See
"Applying styles to a TextField object" on page
on page
144, and
TextFormat.getTextExtent()
TextFormat.getTextExtent()
attribute, or define new tags.
140.
"An example of using styles with XML" on page
method to obtain detailed text measurements
getTextExtent()
on page
TextField.styleSheet
"Loading external CSS files" on page 141
142.
142,
"An example of using styles with HTML"
Formatting text with Cascading Style Sheets
method provides
719.
bodyText
property.
"Creating a style sheet
and
"Creating
146.
.
<p>
139

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Questions and answers

Table of Contents