656 Chapter 12: ActionScript Dictionary
String.substr()
Availability
Flash Player 5.
Usage
my_str.substr(start, [length])
Parameters
start
An integer that indicates the position of the first character in my_str to be used to create
the substring. If
start is a negative number, the starting position is determined from the end of
the string, where the -1 is the last character.
length The number of characters in the substring being created. If length is not specified, the
substring includes all of the characters from the start to the end of the string.
Returns
A substring of the specified string.
Description
Method; returns the characters in a string from the index specified in the start parameter
through the number of characters specified in the
length parameter. The substr method does
not change the string specified by
my_str; it returns a new string.
String.substring()
Availability
Flash Player 5.
Usage
my_str.substring(start, [end])
Parameters
start
An integer that indicates the position of the first character of my_str used to create the
substring. Valid values for
start are 0 through String.length - 1. If start is a negative value,
0 is used.
end An integer that is 1+ the index of the last character in my_str to be extracted. Valid values
for end are 1 through String.length. The character indexed by the end parameter is not
included in the extracted string. If this parameter is omitted,
String.length is used. If this
parameter is a negative value, 0 is used.
Returns
A string.
Description
Method; returns a string consisting of the characters between the points specified by the start
and
end parameters. If the end parameter is not specified, the end of the substring is the end of
the string. If the value of start equals the value of end, the method returns an empty string. If
the value of
start is greater than the value of end, the parameters are automatically swapped
before the function executes and the original value is unchanged.