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"
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...