EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Replacetext (Textfield.replacetext Method)

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
1202 ActionScript classes
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;
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth() method.
See also
setFocus (Selection.setFocus method)
replaceText (TextField.replaceText method)
public replaceText(beginIndex:Number, endIndex:Number, newText:String) :
Void
Replaces a range of characters, specified by the beginIndex and endIndex parameters, in the
specified text field with the contents of the
newText parameter.
Availability: ActionScript 1.0; Flash Player 7
Parameters
beginIndex:Number - The start index value for the replacement range.
endIndex:Number - The end index value for the replacement range.
newText:String - The text to use to replace the specified range of characters.

Table of Contents

Related product manuals