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(in<strong>de</strong>x); // output: -1<br />

Voir également<br />

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

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

longueur publique : Number<br />

Entier spécifiant le nombre <strong>de</strong> caractères dans l'objet String spécifié.<br />

Tous les in<strong>de</strong>x <strong>de</strong> chaîne étant basés sur zéro, l'in<strong>de</strong>x <strong>du</strong> <strong>de</strong>rnier caractère pour une chaîne x<br />

est x.length - 1.<br />

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

Exemple<br />

L'exemple suivant crée un nouvel objet <strong>de</strong> type chaîne et utilise String.length pour en<br />

compter le nombre <strong>de</strong> caractères :<br />

var my_str:String = "Hello world!";<br />

trace(my_str.length); // output: 12<br />

L'exemple suivant boucle <strong>de</strong> 0 à my_str.length. Le co<strong>de</strong> vérifie les caractères au sein d'une<br />

chaîne et, si cette chaîne contient le caractère @, true est affiché dans le panneau <strong>de</strong> sortie. En<br />

l'absence <strong>du</strong> caractère @ le programme affiche false dans le panneau <strong>de</strong> sortie.<br />

function checkAtSymbol(my_str:String):Boolean {<br />

for (var i = 0; i

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

Saved successfully!

Ooh no, something went wrong!