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