MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1209

Actionscript 2.0 language reference
Table of Contents

Advertisement

Notice that any text inserted manually by the user, or replaced by means of
, receives the text field's default formatting for new text, and not
TextField.replaceSel()
the formatting specified for the text insertion point. To set a text field's default formatting for
new text, use
.
TextField.setNewTextFormat()
Availability: ActionScript 1.0; Flash Player 6
Parameters
[optional] - An integer that specifies the first character of the desired
beginIndex:Number
text span. If you do not specify
and
, the TextFormat is applied to the
beginIndex
endIndex
entire TextField.
[optional] - An integer that specifies the first character after the desired
endIndex:Number
text span. If you specify
but do not specify
, the TextFormat is applied
beginIndex
endIndex
to the single character specified by
.
beginIndex
- A TextFormat object, which contains character and paragraph
textFormat:TextFormat
formatting information.
Example
The following example sets the text format for two different strings of text. The
() method is called and applied to the
text field.
setTextFormat
my_txt
var format1_fmt:TextFormat = new TextFormat();
format1_fmt.font = "Arial";
var format2_fmt:TextFormat = new TextFormat();
format2_fmt.font = "Courier";
var string1:String = "Sample string number one."+newline;
var string2:String = "Sample string number two."+newline;
this.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 300, 200);
my_txt.multiline = true;
my_txt.wordWrap = true;
my_txt.text = string1;
var firstIndex:Number = my_txt.length;
my_txt.text += string2;
var secondIndex:Number = my_txt.length;
my_txt.setTextFormat(0, firstIndex, format1_fmt);
my_txt.setTextFormat(firstIndex, secondIndex, format2_fmt);
The
method used in this example requires Flash Player
MovieClip.getNextHighestDepth()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
method.
MovieClip.getNextHighestDepth()
TextField
1209

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents