EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 654

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
654 Chapter 12: ActionScript Dictionary
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 is
x.length - 1.
String.slice()
Availability
Flash Player 5.
Usage
my_str.slice(start, [end])
Parameters
start
A number specifying the index of the starting point for the slice. If start is a negative
number, the starting point is determined from the end of the string, where -1 is the last character.
end An integer that is 1+ the index of the ending point for the slice. The character indexed by
the
end parameter is not included in the extracted string. If this parameter is omitted,
String.length is used. If end is a negative number, the ending point is determined by counting
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 start character and all characters up to (but not
including) the end character. The original String object is not modified. If the end parameter is
not specified, the end of the substring is the end of the string. If the value of
start is greater than
or equal to the value of
end, the method returns an empty string.
Example
The following example sets a variable, text, creates a String object, my_str, and passes it the
text variable. The slice() method extracts a section of the string contained in the variable, and
trace() sends it to the Output panel. The example shows using both a positive and negative
value for the
end parameter.
text = "Lexington";
my_str = new String( text );
trace(my_str.slice( 1, 3 )); // "ex"
trace(my_str.slice( 1, -6 )); // "ex"

Table of Contents

Related product manuals