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.

Example<br />

The following example creates a text field that you can remove from the Stage when you click<br />

the remove_btn instance. Create a button <strong>and</strong> call it remove_btn, <strong>and</strong> then add the following<br />

ActionScript to your FLA or ActionScript file.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 300,<br />

22);<br />

my_txt.text = new Date().toString();<br />

my_txt.border = true;<br />

remove_btn.onRelease = function() {<br />

my_txt.removeTextField();<br />

};<br />

replaceSel (TextField.replaceSel method)<br />

public replaceSel(newText:String) : Void<br />

Replaces the current selection with the contents of the newText parameter. The text is<br />

inserted at the position of the current selection, using the current default character format <strong>and</strong><br />

default paragraph format. The text is not treated as HTML, even if the text field is an HTML<br />

text field.<br />

You can use the replaceSel() method to insert <strong>and</strong> delete text without disrupting the<br />

character <strong>and</strong> paragraph formatting of the rest of the text.<br />

Note: You must use the Selection.setFocus() method to focus the field before you call the<br />

replaceSel() method.<br />

Parameters<br />

newText:String - A string.<br />

Example<br />

The following example code creates a multiline text field with text on the Stage. When you<br />

select some text <strong>and</strong> then right-click or Control-click over the text field, you can select Enter<br />

current date from the context menu. This selection calls a function that replaces the<br />

selected text with the current date.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320,<br />

240);<br />

my_txt.border = true;<br />

my_txt.wordWrap = true;<br />

my_txt.multiline = true;<br />

my_txt.type = "input";<br />

my_txt.text = "Select some sample text from the text field <strong>and</strong> then rightclick/control<br />

click "<br />

636 ActionScript classes

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

Saved successfully!

Ooh no, something went wrong!