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.

Voir également<br />

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

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

public lastIn<strong>de</strong>xOf(value:String, [startIn<strong>de</strong>x:Number]) : Number<br />

Recherche la chaîne <strong>de</strong> droite à gauche et renvoie l'in<strong>de</strong>x <strong>de</strong> la <strong>de</strong>rnière occurrence <strong>de</strong> value<br />

détectée avant startIn<strong>de</strong>x dans la chaîne appelante. Cet in<strong>de</strong>x est basé sur zéro, ce qui<br />

signifie que le premier caractère dans une chaîne est considéré comme étant à l'in<strong>de</strong>x 0, pas<br />

l'in<strong>de</strong>x 1. Si value n'est pas détectée, la métho<strong>de</strong> renvoie -1.<br />

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

Paramètres<br />

value:String - Chaîne à rechercher.<br />

startIn<strong>de</strong>x:Number [facultatif] - Entier spécifiant le point <strong>de</strong> départ <strong>de</strong> la recherche <strong>de</strong><br />

value.<br />

Valeur renvoyée<br />

Number - Position <strong>de</strong> la <strong>de</strong>rnière occurrence <strong>de</strong> la sous-chaîne spécifiée ou -1.<br />

Exemple<br />

L'exemple suivant indique comment utiliser lastIn<strong>de</strong>xOf() pour renvoyer l'in<strong>de</strong>x d'un<br />

caractère :<br />

var searchString:String = "Lorem ipsum dolor sit amet.";<br />

var in<strong>de</strong>x:Number;<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("L");<br />

trace(in<strong>de</strong>x); // output: 0<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("l");<br />

trace(in<strong>de</strong>x); // output: 14<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("i");<br />

trace(in<strong>de</strong>x); // output: 19<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("ipsum");<br />

trace(in<strong>de</strong>x); // output: 6<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("i", 18);<br />

trace(in<strong>de</strong>x); // output: 6<br />

in<strong>de</strong>x = searchString.lastIn<strong>de</strong>xOf("z");<br />

1172 Chapitre 2: Classes <strong>ActionScript</strong>

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

Saved successfully!

Ooh no, something went wrong!