03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

See also<br />

sort (Array.sort method), sortOn (Array.sortOn method)<br />

concat (Array.concat method)<br />

public concat([value:Object]) : Array<br />

Concatenates the elements specified in the parameters with the elements in an array <strong>and</strong><br />

creates a new array. If the value parameters specify an array, the elements of that array are<br />

concatenated, rather than the array itself. The array my_array is left unchanged.<br />

Parameters<br />

value:Object [optional] - Numbers, elements, or strings to be concatenated in a new array.<br />

If you don't pass any values, a duplicate of my_array is created.<br />

Returns<br />

Array - An array that contains the elements from this array followed by elements from the<br />

parameters.<br />

Example<br />

The following code concatenates two arrays:<br />

var alpha_array:Array = new Array("a","b","c");<br />

var numeric_array:Array = new Array(1,2,3);<br />

var alphaNumeric_array:Array =alpha_array.concat(numeric_array);<br />

trace(alphaNumeric_array);<br />

// Creates array [a,b,c,1,2,3].<br />

The following code concatenates three arrays:<br />

var num1_array:Array = [1,3,5];<br />

var num2_array:Array = [2,4,6];<br />

var num3_array:Array = [7,8,9];<br />

var nums_array:Array=num1_array.concat(num2_array,num3_array)<br />

trace(nums_array);<br />

// Creates array [1,3,5,2,4,6,7,8,9].<br />

Nested arrays are not flattened in the same way as normal arrays. The elements in a nested<br />

array are not broken into separate elements in array x_array, as shown in the following<br />

example:<br />

var a_array:Array = new Array ("a","b","c");<br />

// 2 <strong>and</strong> 3 are elements in a nested array.<br />

var n_array:Array = new Array(1, [2, 3], 4);<br />

var x_array:Array = a_array.concat(n_array);<br />

236 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!