EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Getbeginindex (Selection.getbeginindex 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...
Selection 1071
When you test the SWF file, try using Tab to move between the two text fields. Make sure
that you select Control > Disable Keyboard Shortcuts so you can change focus between the
two fields using Tab.
See also
setFocus (Selection.setFocus method)
getBeginIndex (Selection.getBeginIndex method)
public static getBeginIndex() : Number
Returns the index at the beginning of the selection span. If no index exists or no text field
currently has focus, the method returns -1. Selection span indexes are zero-based (for example,
the first position is 0, the second position is 1, and so on).
Availability: ActionScript 1.0; Flash Player 5
Returns
Number - An integer.
Example
The following example creates a text field at runtime, and sets its properties. A context menu
item is added that can be used to change the currently selected text to uppercase characters.
this.createTextField("output_txt", this.getNextHighestDepth(), 0, 0, 300,
200);
output_txt.multiline = true;
output_txt.wordWrap = true;
output_txt.border = true;
output_txt.type = "input";
output_txt.text = "Enter your text here";
var my_cm:ContextMenu = new ContextMenu();
my_cm.customItems.push(new ContextMenuItem("Uppercase...", doUppercase));
function doUppercase():Void {
var startIndex:Number = Selection.getBeginIndex();
var endIndex:Number = Selection.getEndIndex();
var stringToUppercase:String = output_txt.text.substring(startIndex,
endIndex);
output_txt.replaceText(startIndex, endIndex,
stringToUppercase.toUpperCase());
}
output_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.

Table of Contents

Related product manuals