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.

index = searchString.lastIndexOf("i");<br />

trace(index); // output: 19<br />

index = searchString.lastIndexOf("ipsum");<br />

trace(index); // output: 6<br />

index = searchString.lastIndexOf("i", 18);<br />

trace(index); // output: 6<br />

index = searchString.lastIndexOf("z");<br />

trace(index); // output: -1<br />

See also<br />

indexOf (String.indexOf method)<br />

length (String.length property)<br />

public length : Number<br />

An integer specifying the number of characters in the specified String object.<br />

Because all string indexes are zero-based, the index of the last character for any string x is<br />

x.length - 1.<br />

Example<br />

The following example creates a new String object <strong>and</strong> uses String.length to count the<br />

number of characters:<br />

var my_str:String = "Hello world!";<br />

trace(my_str.length); // output: 12<br />

The following example loops from 0 to my_str.length. The code checks the characters<br />

within a string, <strong>and</strong> if the string contains the @ character, true displays in the Output panel. If<br />

it does not contain the @ character, then false displays in the Output panel.<br />

function checkAtSymbol(my_str:String):Boolean {<br />

for (var i = 0; i

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

Saved successfully!

Ooh no, something went wrong!