String Constructor - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

trace(my_array[i]);
}
// output:
P
A
T
S
Y
The following example returns an array with two elements,
var my_str:String = "P,A,T,S,Y";
var my_array:Array = my_str.split(",", 2);
trace(my_array); // output: P,A
The following example shows that if you use an empty string ("") for the
parameter, each character in the string is placed as an element in the array:
var my_str:String = new String("Joe");
var my_array:Array = my_str.split("");
for (var i = 0; i<my_array.length; i++) {
trace(my_array[i]);
}
// output:
J
o
e
An example is also in the Strings.fla file in the ActionScript samples folder. The following list
gives typical paths to this folder:
Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript
Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/
Samples/ActionScript
See also
join (Array.join method)

String constructor

public String(value:String)
Creates a new String object.
Because string literals use less overhead than String objects and are generally easier to
use, you should use string literals instead of the constructor for the String class unless
you have a good reason to use a String object rather than a string literal.
1136
ActionScript classes
and
:
"P"
"A"
delimiter

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents