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.

trace(a_array.join(" + "));<br />

// Displays Earth + Moon + Sun.<br />

L'exemple suivant crée un tableau incorporé qui contient <strong>de</strong>ux tableaux. Le premier tableau<br />

inclut trois éléments : Europa, Io et Callisto. Le <strong>de</strong>uxième tableau inclut <strong>de</strong>ux éléments : Titan<br />

et Rhea. Il relie le tableau à l'ai<strong>de</strong> d'un signe plus (+) mais les éléments <strong>de</strong> chaque tableau<br />

incorporé restent séparés par <strong>de</strong>s virgules (,).<br />

var a_nested_array:Array = new Array(["Europa", "Io", "Callisto"],<br />

["Titan", "Rhea"]);<br />

trace(a_nested_array.join(" + "));<br />

// Returns Europa,Io,Callisto + Titan,Rhea.<br />

Voir également<br />

split (métho<strong>de</strong> String.split)<br />

length (propriété Array.length)<br />

public length : Number<br />

Un entier non négatif spécifiant le nombre d'éléments contenus dans le tableau. Cette<br />

propriété est automatiquement mise à jour lorsque vous ajoutez <strong>de</strong> nouveaux éléments dans le<br />

tableau. Lorsque vous affectez une valeur à un élément <strong>de</strong> tableau (par exemple,<br />

my_array[in<strong>de</strong>x] = value), si in<strong>de</strong>x est un nombre et si in<strong>de</strong>x+1 est supérieur à la<br />

propriété length, la propriété length est mise à jour et définie sur la valeur in<strong>de</strong>x+1.<br />

Remarque : Si vous affectez une valeur plus courte que la valeur existante à la propriété<br />

length, le tableau sera tronqué.<br />

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

Exemple<br />

Le co<strong>de</strong> suivant explique la façon dont la propriété length est mise à jour. La valeur <strong>de</strong> la<br />

longueur initiale est 0, puis 1, 2 et 10. Si vous affectez une valeur plus courte que la valeur<br />

existante à la propriété length, le tableau sera tronqué :<br />

var my_array:Array = new Array();<br />

trace(my_array.length); // initial length is 0<br />

my_array[0] = "a";<br />

trace(my_array.length); // my_array.length is updated to 1<br />

my_array[1] = "b";<br />

trace(my_array.length); // my_array.length is updated to 2<br />

my_array[9] = "c";<br />

trace(my_array.length); // my_array.length is updated to 10<br />

trace(my_array);<br />

// displays:<br />

Array 257

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

Saved successfully!

Ooh no, something went wrong!