User Guide

728 Chapter 7: ActionScript for Flash
Description
Method; returns a TextFormat object containing a copy of the text field’s text format object. The
text format object is the format that newly inserted text, such as text inserted with the
replaceSel() method or text entered by a user, receives. When getNewTextFormat() is
invoked, the TextFormat object returned has all of its properties defined. No property is
null.
Example
The following example displays the specified text field’s (my_txt) text format object.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 120);
var my_fmt:TextFormat = my_txt.getNewTextFormat();
trace("TextFormat has the following properties:");
for (var prop in my_fmt) {
trace(prop+": "+my_fmt[prop]);
}
TextField.getTextFormat()
Availability
Flash Player 6.
Usage
my_txt.getTextFormat() : Object
my_txt.getTextFormat(index:Number) : Object
my_txt.getTextFormat(beginIndex:Number, endIndex:Number) : Object
Parameters
index
An integer that specifies a character in a string.
beginIndex, endIndex Integers that specify the starting and ending locations of a span of text
within
my_txt.
Returns
An object.
Description
Method; returns a TextFormat object containing a particular kind of information.
Usage 1: returns a TextFormat object containing formatting information for all text in a text field.
Only properties that are common to all text in the text field are set in the resulting TextFormat
object. Any property which is mixed, meaning that it has different values at different points in the
text, has a value of
null.
Usage 2: Returns a TextFormat object containing a copy of the text field’s text format at index.
Usage 3: Returns a TextFormat object containing formatting information for the span of text
from
beginIndex to endIndex. Only properties that are common to all of the text in the
specified range is set in the resulting TextFormat object. Any property that is mixed (it has
different values at different points in the range) has its value set to null.