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.

Paramètres<br />

numElements:Number [facultatif] - Un entier positif spécifiant le nombre d'éléments<br />

contenus dans le tableau. Vous pouvez spécifier numElements ou la liste <strong>de</strong>s éléments, mais<br />

pas les <strong>de</strong>ux.<br />

elementN:Object [facultatif] - Un ou plusieurs paramètres, element0, element1, ... ,<br />

elementN, dont les valeurs peuvent être <strong>de</strong> n'importe quel type. Les paramètres qui peuvent<br />

accepter plusieurs types <strong>de</strong> données sont répertoriés sous le type Object. Vous pouvez<br />

spécifier numElements ou la liste <strong>de</strong>s éléments, mais pas les <strong>de</strong>ux.<br />

Renvoie<br />

Array - Un tableau.<br />

Exemple<br />

var myArray:Array = Array();<br />

myArray.push(12);<br />

trace(myArray); //traces 12<br />

myArray[4] = 7;<br />

trace(myArray); //traces 12,un<strong>de</strong>fined,un<strong>de</strong>fined,un<strong>de</strong>fined,7<br />

Utilisation 2 : L'exemple suivant crée un tableau <strong>de</strong> longueur 4 qui n'inclut aucun élément<br />

défini :<br />

var myArray:Array = Array(4);<br />

trace(myArray.length); // traces 4<br />

trace(myArray); // traces un<strong>de</strong>fined,un<strong>de</strong>fined,un<strong>de</strong>fined,un<strong>de</strong>fined<br />

Utilisation 3 : L'exemple suivant crée un tableau incluant trois éléments définis :<br />

var myArray:Array = Array("firstElement", "secondElement", "thirdElement");<br />

trace (myArray); // traces firstElement,secondElement,thirdElement<br />

Unlike the Array class constructor, the Array() function does not use the<br />

keyword new .<br />

Voir également<br />

Array<br />

Protocole asfunction<br />

asfunction:function:Function, parameter:String<br />

48 Chapitre 1: Eléments <strong>du</strong> <strong>langage</strong> <strong>ActionScript</strong>

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

Saved successfully!

Ooh no, something went wrong!