![MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual Download Page 702](http://html1.mh-extra.com/html/macromedia/flash-mx-2004-actionscript/flash-mx-2004-actionscript_reference-manual_3378897702.webp)
702
Chapter 12: ActionScript Dictionary
TextField.setTextFormat()
Availability
Flash Player 6.
Usage
my_txt
.setTextFormat (
textFormat
)
my_txt
.setTextFormat (
index
,
textFormat
)
my_txt
.setTextFormat (
beginIndex
,
endIndex
,
textFormat
)
Parameters
textFormat
A TextFormat object, which contains character and paragraph formatting
information.
index
An integer that specifies a character within
my_txt
.
beginIndex
An integer.
endIndex
An integer that specifies the first character after the desired text span.
Returns
Nothing.
Description
Method; sets a TextFormat object for a specified range of text in a text field. You can assign each
character in a text field a text format. The text format of the first character of a paragraph is
examined to perform paragraph formatting for the entire paragraph. The
setTextFormat()
method changes the text format applied to individual characters, to groups of characters, or to the
entire body of text in a text field.
The text format is set in a new TextFormat object. It contains both character and paragraph
formatting information. Character formatting information describes the appearance of individual
characters, for example, font name, point size, color, and associated URL. Paragraph formatting
information describes the appearance of a paragraph, for example, left margin, right margin,
indentation of the first line, and left, right, and center alignment.
Usage 1: Applies the properties of
textFormat
to all text in the text field.
Usage 2: Applies the properties of
textFormat
to the character at position
index
.
Usage 3: Applies the properties of the
textFormat
parameter to the span of text from the
beginIndex
parameter to the
endIndex
parameter.
Notice that any text inserted manually by the user, or replaced by means of
TextField.replaceSel()
, does not assume the formatting specified in a call to
setTextFormat()
. To set the default formatting for a TextField object, use
TextField.setNewTextFormat()
.
Example
This example creates a new TextFormat object called
myTextFormat
and sets its
bold
property to
true
. It then calls
setTextFormat()
and applies the new text format to the
my_txt
text field.
myTextFormat = new TextFormat();
myTextFormat.bold = true;
my_txt.setTextFormat(myTextFormat);
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...