416
Chapter 6: ActionScript Core Classes
// slices that omit the end parameter use String.length, which equals 5
trace("slice(0): "+my_str.slice(0)); // slice(0): Lorem
trace("slice(3): "+my_str.slice(3)); // slice(3): em
See also
String.substr()
,
String.substring()
String.split()
Availability
Flash Player 5.
Usage
my_str
.split("
delimiter
"
:String
, [
limit:Number
])
: Array
Parameters
delimiter
A string; the character or string at which
my_str
splits.
limit
A number; the number of items to place into the array. This parameter is optional.
Returns
An array; an array containing the substrings of
my_str
.
Description
Method; splits a String object into substrings by breaking it wherever the specified
delimiter
parameter occurs and returns the substrings in an array. If you use an empty string (
""
) as a
delimiter, each character in the string is placed as an element in the array.
If the
delimiter
parameter is undefined, the entire string is placed into the first element of the
returned array.
Example
The following example returns an array with five elements:
var my_str:String = "P,A,T,S,Y";
var my_array:Array = my_str.split(",");
for (var i = 0; i<my_array.length; i++) {
trace(my_array[i]);
}
/* output:
P
A
T
S
Y
*/
The following example returns an array with two elements,
"P"
and
"A"
:
var my_str:String = "P,A,T,S,Y";
var my_array:Array = my_str.split(",", 2);
trace(my_array); // output: P,A
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...