Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Array > join (Array.join method) | |||
public join([delimiter:String]) : String
Converts the elements in an array to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string. A nested array is always separated by a comma (,), not by the separator passed to the join() method.
Availability: ActionScript 1.0; Flash Player 5
delimiter:String [optional] - A character or string that separates array elements in the returned string. If you omit this parameter, a comma (,) is used as the default separator.
String - A string.
The following example creates an array with three elements: Earth, Moon, and Sun. It then joins the array three times--first by using the default separator (a comma [,] and a space), then by using a dash (-), and then by using a plus sign (+).
var a_array:Array = new Array("Earth","Moon","Sun")
trace(a_array.join());
// Displays Earth,Moon,Sun.
trace(a_array.join(" - "));
// Displays Earth - Moon - Sun.
trace(a_array.join(" + "));
// Displays Earth + Moon + Sun.
The following example creates a nested array that contains two arrays. The first array has three elements: Europa, Io, and Callisto. The second array has two elements: Titan and Rhea. It joins the array by using a plus sign (+), but the elements within each nested array remain separated by commas (,).
var a_nested_array:Array = new Array(["Europa", "Io", "Callisto"], ["Titan", "Rhea"]);
trace(a_nested_array.join(" + "));
// Returns Europa,Io,Callisto + Titan,Rhea.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001357.html