Description
Method; returns a string comprising the characters represented by the ASCII values in
the parameters.
Example
The following example uses
var address_str:String = "dog"+String.fromCharCode(64)+"house.net";
trace(address_str); // output: dog@house.net
String.indexOf()
Availability
Flash Player 5.
Usage
my_str.indexOf(substring:String, [startIndex:Number])
Parameters
A string; the substring to be searched for within
substring
A number; an optional integer specifying the starting point in
startIndex
the substring.
Returns
A number; the position of the first occurrence of the specified substring or -1.
Description
Method; searches the string and returns the position of the first occurrence of
found at or after
first character in a string is considered to be at index 0—not index 1. If
the method returns -1.
Example
The following examples use
var searchString:String = "Lorem ipsum dolor sit amet.";
var index:Number;
index = searchString.indexOf("L");
trace(index); // output: 0
index = searchString.indexOf("l");
trace(index); // output: 14
index = searchString.indexOf("i");
trace(index); // output: 6
index = searchString.indexOf("ipsum");
trace(index); // output: 6
412
Chapter 6: ActionScript Core Classes
fromCharCode()
within the calling string. This index is zero-based, meaning that the
startIndex
indexOf()
to insert an
character in the e-mail address:
@
to return the index of characters and substrings:
.
my_str
my_str
substring
is not found,
substring
to search for
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers