Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > TextFormat | |||
Object
|
+-TextFormat
public class TextFormat
extends Object
The TextFormat class represents character formatting information. Use the TextFormat class to create specific text formatting for text fields. You can apply text formatting to both static and dynamic text fields. Some properties of the TextFormat class are not available for both embedded and device fonts.
You must use the constructor new TextFormat() to create a TextFormat object before calling its methods.
You can set TextFormat parameters to null to indicate that they are undefined. When you apply a TextFormat object to a text field using TextField.setTextFormat(), only its defined properties are applied, as in the following example:
this.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
my_txt.autoSize = true;
my_txt.text = "Lorem ipsum dolor sit amet...";
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;
my_txt.setTextFormat(my_fmt);
This code first creates an empty TextFormat object with all of its properties null, and then sets the bold property to a defined value. The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the MovieClip.getNextHighestDepth() method.
The code my_txt.setTextFormat(my_fmt) only changes the bold property of the text field's default text format, because the bold property is the only one defined in my_fmt . All other aspects of the text field's default text format remain unchanged.
When TextField.getTextFormat() is invoked, a TextFormat object is returned with all of its properties defined; no property is null.
Availability: ActionScript 1.0; Flash Player 6
setTextFormat (TextField.setTextFormat method), getTextFormat (TextField.getTextFormat method)
|
Modifiers |
Property |
Description |
|---|---|---|
|
|
align |
A string that indicates the alignment of the paragraph. |
|
|
blockIndent |
A number that indicates the block indentation in points. |
|
|
bold |
A Boolean value that specifies whether the text is boldface. |
|
|
bullet |
A Boolean value that indicates that the text is part of a bulleted list. |
|
|
color |
Indicates the color of text. |
|
|
font |
The name of the font for text in this text format, as a string. |
|
|
indent |
An integer that indicates the indentation from the left margin to the first character in the paragraph. |
|
|
italic |
A Boolean value that indicates whether text in this text format is italicized. |
|
|
kerning |
A Boolean value that indicates whether kerning is enabled or disabled. |
|
|
leading |
An integer that represents the amount of vertical space in pixels (called leading) between lines. |
|
|
leftMargin |
The left margin of the paragraph, in points. |
|
|
letterSpacing |
The amount of space that is uniformly distributed between characters. |
|
|
rightMargin |
The right margin of the paragraph, in points. |
|
|
size |
The point size of text in this text format. |
|
|
tabStops |
Specifies custom tab stops as an array of non-negative integers. |
|
|
target |
Indicates the target window where the hyperlink is displayed. |
|
|
underline |
A Boolean value that indicates whether the text that uses this text format is underlined ( |
|
|
url |
Indicates the URL that text in this text format hyperlinks to. |
Properties inherited from class Object
|
Signature |
Description |
|---|---|
|
TextFormat |
Creates a TextFormat object with the specified properties. |
|
Modifiers |
Signature |
Description |
|---|---|---|
|
|
getTextExtent |
Deprecated since Flash Player 8. There is no replacement. Returns text measurement information for the text string |
Methods inherited from class Object addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch
Version 8
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00002801.html