03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - 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.

getEndIndex (Selection.getEndIndex method)<br />

public static getEndIndex() : Number<br />

Returns the ending index of the currently focused selection span. If no index exists, or if there<br />

is no currently focused selection span, the method returns -1. Selection span indexes are zerobased<br />

(for example, the first position is 0, the second position is 1, <strong>and</strong> so on).<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Returns<br />

Number - An integer.<br />

Example<br />

This example is excerpted from the Strings.fla file in the <strong>ActionScript</strong> samples folder.<br />

// define the function which converts the selected text in an instance,<br />

// <strong>and</strong> convert the string to upper or lower case.<br />

function convertCase(target, menuItem) {<br />

var beginIndex:Number = Selection.getBeginIndex();<br />

var endIndex:Number = Selection.getEndIndex();<br />

var tempString:String;<br />

// make sure that text is actually selected.<br />

if (beginIndex>-1 && endIndex>-1) {<br />

// set the temporary string to the text before the selected text.<br />

tempString = target.text.slice(0, beginIndex);<br />

switch (menuItem.caption) {<br />

case 'Uppercase...' :<br />

// if the user selects the "Uppercase..." context menu item,<br />

// convert the selected text to upper case.<br />

tempString += target.text.substring(beginIndex,<br />

endIndex).toUpperCase();<br />

break;<br />

case 'Lowercase...' :<br />

tempString += target.text.substring(beginIndex,<br />

endIndex).toLowerCase();<br />

break;<br />

}<br />

// append the text after the selected text to the temporary string.<br />

tempString += target.text.slice(endIndex);<br />

// set the text in the target text field to the contents of the temporary<br />

string.<br />

target.text = tempString;<br />

}<br />

}<br />

For the entire script, see the Flash Samples page at www.adobe.com/go/learn_fl_samples.<br />

Download <strong>and</strong> decompress the Samples zip file <strong>and</strong> go to the <strong>ActionScript</strong><strong>2.0</strong>\Strings folder<br />

to access the Strings.fla file.<br />

1088 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!