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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

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

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

index = searchString.indexOf("i", 7);<br />

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

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

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

See also<br />

lastIndexOf (String.lastIndexOf method)<br />

lastIndexOf (String.lastIndexOf method)<br />

public lastIndexOf(value:String, [startIndex:Number]) : Number<br />

Searches the string from right to left <strong>and</strong> returns the index of the last occurrence of value<br />

found before startIndex within the calling string. This index is zero-based, meaning that the<br />

first character in a string is considered to be at index 0--not index 1. If value is not found, the<br />

method returns -1.<br />

Parameters<br />

value:String - The string for which to search.<br />

startIndex:Number [optional] - An integer specifying the starting point from which to<br />

search for value.<br />

Returns<br />

Number - The position of the last occurrence of the specified substring or -1.<br />

Example<br />

The following example shows how to use lastIndexOf() to return the index of a certain<br />

character:<br />

var searchString:String = "Lorem ipsum dolor sit amet.";<br />

var index:Number;<br />

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

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

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

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

String 597

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

Saved successfully!

Ooh no, something went wrong!