276
Chapter 12: ActionScript Dictionary
Array.concat()
Availability
Flash Player 5.
Usage
my_array
.concat( [
value0, value1,...valueN
])
Parameters
value0,...valueN
Numbers, elements, or strings to be concatenated in a new array. If you
don’t pass any values, a duplicate of
my_array
is created.
Returns
Nothing.
Description
Method; concatenates the elements specified in the parameters with the elements in
my_array
,
and creates a new array. If the
value
parameters specify an array, the elements of that array are
concatenated, rather than the array itself. The array
my_array
is left unchanged.
Example
The following code concatenates two arrays.
alpha_array = new Array("a","b","c");
numeric_array = new Array(1,2,3);
alphaNumeric_array=alpha_array.concat(numeric_array);
trace(alphaNumeric_array);
// creates array ["a","b","c",1,2,3]
The following code concatenates three arrays.
num1_array = [1,3,5];
num2_array = [2,4,6];
num3_array = [7,8,9];
nums_array=num1_array.concat(num2_array,num3_array)
trace(nums_array);
// creates array [1,3,5,2,4,6,7,8,9]
Nested arrays are not flattened in the same way normal arrays are. The elements in a nested array
are not broken into separate elements in array
x_array
, as in the following example.
a_array = new Array ("a","b","c");
// 2 and 3 are elements in a nested array
n_array = new Array(1, [2, 3], 4);
x_array = a_array.concat(n_array);
trace(x_array[0]); // "a"
trace(x_array[1]); // "b"
trace(x_array[2]); // "c"
trace(x_array[3]); // 1
trace(x_array[4]); // 2, 3
trace(x_array[5]); // 4
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...