03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

concat (métho<strong>de</strong> Array.concat)<br />

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

Concatène les éléments spécifiés dans les paramètres avec ceux contenus dans un tableau et<br />

crée un nouveau tableau. Si les paramètres value spécifient un tableau, les éléments <strong>de</strong> celuici<br />

sont concaténés, au lieu <strong>du</strong> tableau lui-même. Le tableau my_array <strong>de</strong>meure inchangé.<br />

Disponibilité : <strong>ActionScript</strong> 1.0 ; Flash Player 5<br />

Paramètres<br />

value:Object [facultatif] - Nombres, éléments ou chaînes à concaténer dans un nouveau<br />

tableau. Si vous ne transmettez aucune valeur, une <strong>du</strong>plication <strong>de</strong> my_array est créée.<br />

Renvoie<br />

Array - Un tableau qui contient les éléments <strong>de</strong> ce tableau suivi <strong>de</strong>s éléments <strong>de</strong>s paramètres.<br />

Exemple<br />

Le co<strong>de</strong> suivant concatène <strong>de</strong>ux tableaux :<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 />

Le co<strong>de</strong> suivant concatène trois tableaux :<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 />

Les tableaux incorporés ne sont pas aplatis <strong>de</strong> la même manière que les tableaux normaux. Les<br />

éléments d'un tableau incorporé ne sont pas séparés en éléments distincts dans le tableau<br />

x_array, comme indiqué dans l'exemple suivant :<br />

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

// 2 and 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 />

trace(x_array[0]); // a<br />

trace(x_array[1]); // b<br />

trace(x_array[2]); // c<br />

trace(x_array[3]); // 1<br />

Array 255

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

Saved successfully!

Ooh no, something went wrong!