MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 744

Actionscript language reference
Table of Contents

Advertisement

Returns
Nothing.
Description
Method; replaces the current selection with the contents of the
inserted at the position of the current selection, using the current default character format and
default paragraph format. The text is not treated as HTML, even if the text field is an HTML
text field.
You can use the
and paragraph formatting of the rest of the text.
You must use
Selection.setFocus()
Example
The following example code creates a multiline text field with text on the Stage. When you select
some text and then right-click or Control-click over the text field, you can select Enter current
date from the context menu. This selection calls a function that replaces the selected text with the
current date.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 240);
my_txt.border = true;
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.type = "input";
my_txt.text = "Select some sample text from the text field and then right-
click/control click and select 'Enter current date' from the context menu to
replace the currently selected text with the current date.";
var my_cm:ContextMenu = new ContextMenu();
my_cm.customItems.push(new ContextMenuItem("Enter current date", enterDate));
function enterDate(obj:Object, menuItem:ContextMenuItem) {
var today_str:String = new Date().toString();
var date_str:String = today_str.split(" ", 3).join(" ");
my_txt.replaceSel(date_str);
}
my_txt.menu = my_cm;
See also
Selection.setFocus()
TextField.replaceText()
Availability
Flash Player 7.
Usage
my_txt.replaceText(beginIndex:Number, endIndex:Number, text:String) : Void
744
Chapter 7: ActionScript for Flash
method to insert and delete text without disrupting the character
replaceSel()
to focus the field before issuing this command.
parameter. The text is
text

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents