T > TextFormat (object)

 

TextFormat (object)

The TextFormat object represents character formatting information.

You must use the constructor new TextFormat to create an instance of the 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 the setTextFormat method, only its defined properties are applied, as in the following example:

myTextFormat = new TextFormat();
myTextFormat.bold = true;
myTextField.setTextFormat(myTextFormat);

This code first creates an empty TextFormat object with all of its properties undefined, then sets the bold property to a defined value.

The code myTextField.setTextFormat(myTextFormat) only changes the bold property of the text field's default text format, because the bold property is the only one defined in myTextFormat. All other aspects of the text field's default text format remain unchanged.

When getTextFormat is invoked, a TextFormat object is returned with all of its properties defined; no property is null.

 
Method summary for the TextFormat object

Method

Description

TextFormat.getTextExtent

Returns an object with two properties, width and height, that indicate the size of text in a text field.


 
Property summary for the TextFormat object

Property

Description

TextFormat.align

Indicates the alignment of a paragraph.

TextFormat.blockIndent

Indicates the block indentation in points.

TextFormat.bold

Indicates whether text is boldface.

TextFormat.bullet

Indicates whether or not text is in a bulleted list.

TextFormat.color

Indicates the color of text.

TextFormat.font

Indicates the font name of the text with a text format.

TextFormat.indent

Indicates the indentation from the left margin to the first character in the paragraph.

TextFormat.italic

Indicates whether text is italicized.

TextFormat.leading

Indicates the amount of leading vertical space between lines.

TextFormat.leftMargin

Indicates the left margin of the paragraph, in points.

TextFormat.rightMargin

Indicates the right margin of the paragraph, in points.

TextFormat.tabStops

Specifies custom tab stops.

TextFormat.target

Indicates the window in a browser where a hyperlink is displayed.

TextFormat.size

Indicates the point size of text.

TextFormat.underline

Indicates whether text is underlined.

TextFormat.url

Indicates the URL to which the text links.


 
Constructor for the TextFormat object

Usage

new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, [target, [align, [leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])

Parameters

font The name of a font for text as a string.

size An integer that indicates the point size.

color The color of text using this text format. A number containing three 8-bit RGB components; for example, 0xFF0000 is red, 0x00FF00 is green.

bold A Boolean value that indicates whether the text is boldface.

italic A Boolean value that indicates whether the text is italicized.

underline A Boolean value that indicates whether the text is underlined.

url The URL to which the text in this text format hyperlinks. If url is an empty string, the text does not have a hyperlink.

target The target window where the hyperlink is displayed. If the target window is an empty string, the text is displayed in the default target window _self. If the TextFormat.url property is set to empty string or to the value null, this property may be get or set but has no effect.

align The alignment of the paragraph, represented as a string. If "left", the paragraph is left-aligned. If "center", the paragraph is centered. If "right", the paragraph is right-aligned.

leftMargin Indicates the left margin of the paragraph, in points.

rightMargin Indicates the right margin of the paragraph, in points.

indent An integer that indicates the indentation from the left margin to the first character in the paragraph.

leading A number that indicates the amount of leading vertical space between lines.

Description

Constructor; creates an instance of the TextFormat object with the specified properties. You can then change the properties of the TextFormat object to change the formatting of text fields.

Any parameter may be set to the value null to indicate that it is not defined. All of the parameters are optional; any omitted parameters are treated as null.

Availability

Flash Player 6.