03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

■ Usage 3:my_textField.setTextFormat(beginIndex:Number, endIndex:Number,<br />

textFormat:TextFormat)<br />

Applies the properties of the textFormat parameter to the span of text from the<br />

beginIndex position to the endIndex position.<br />

Notice that any text inserted manually by the user receives the text field's default formatting<br />

for new text, <strong>and</strong> not the formatting specified for the text insertion point. To set a text field's<br />

default formatting for new text, use TextField.setNewTextFormat().<br />

Parameters<br />

beginIndex:Number [optional] - An integer that specifies the first character of the desired<br />

text span. If you do not specify beginIndex <strong>and</strong> endIndex, the TextFormat is applied to the<br />

entire TextField.<br />

endIndex:Number [optional] - An integer that specifies the first character after the desired<br />

text span. If you specify beginIndex but(do not specify endIndex, the TextFormat is applied<br />

to the single character specified by beginIndex.<br />

textFormat:TextFormat - A TextFormat object, which contains character <strong>and</strong> paragraph<br />

formatting information.<br />

Example<br />

The following example sets the text format for two different strings of text. The<br />

setTextFormat() method is called <strong>and</strong> applied to the my_txt text field.<br />

var format1_fmt:TextFormat = new TextFormat();<br />

format1_fmt.font = "Arial";<br />

var format2_fmt:TextFormat = new TextFormat();<br />

format2_fmt.font = "Courier";<br />

var string1:String = "Sample string number one."+newline;<br />

var string2:String = "Sample string number two."+newline;<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 300, 200);<br />

my_txt.multiline = true;<br />

my_txt.wordWrap = true;<br />

my_txt.text = string1;<br />

var firstIndex:Number = my_txt.length;<br />

my_txt.text += string2;<br />

var secondIndex:Number = my_txt.length;<br />

my_txt.setTextFormat(0, firstIndex, format1_fmt);<br />

my_txt.setTextFormat(firstIndex, secondIndex, format2_fmt);<br />

642 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!