String.length
Availability
Flash Player 5.
Usage
my_str.length
Description
Property; a nonzero-based integer specifying the number of characters in the specified String
object.
Because all string indexes are zero-based, the index of the last character for any string
.
x.length - 1
String.slice()
Availability
Flash Player 5.
Usage
my_str.slice(start, [end])
Parameters
A number specifying the index of the starting point for the slice. If
start
number, the starting point is determined from the end of the string, where -1 is the last character.
An integer that is 1+ the index of the ending point for the slice. The character indexed by
end
the
parameter is not included in the extracted string. If this parameter is omitted,
end
String.length
back from the end of the string, where -1 is the last character.
Returns
A substring of the specified string.
Description
Method; returns a string that includes the
including) the
end
not specified, the end of the substring is the end of the string. If the value of
or equal to the value of
Example
The following example sets a variable,
variable. The
text
sends it to the Output panel. The example shows using both a positive and negative
trace()
value for the
end
text = "Lexington";
my_str = new String( text );
trace(my_str.slice( 1, 3 )); // "ex"
trace(my_str.slice( 1, -6 )); // "ex"
654
Chapter 12: ActionScript Dictionary
is used. If
is a negative number, the ending point is determined by counting
end
character. The original String object is not modified. If the
, the method returns an empty string.
end
text
method extracts a section of the string contained in the variable, and
slice()
parameter.
character and all characters up to (but not
start
, creates a String object,
is
x
is a negative
start
parameter is
end
is greater than
start
, and passes it the
my_str
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?