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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

public toString() : String<br />

Renvoie les propriétés d'un objet en tant que chaînes, que ces propriétés soient <strong>de</strong>s chaînes ou<br />

non.<br />

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

Valeur renvoyée<br />

String - Chaîne.<br />

Exemple<br />

Le co<strong>de</strong> suivant renvoie une chaîne en majuscules qui donne la liste <strong>de</strong> l'ensemble <strong>de</strong>s<br />

propriétés d'un objet, que les propriétés soient <strong>de</strong>s chaînes ou non :<br />

var employee:Object = new Object();<br />

employee.name = "bob";<br />

employee.salary = 60000;<br />

employee.id = 284759021;<br />

var employeeData:String = new String();<br />

for (prop in employee)<br />

{<br />

employeeData += employee[prop].toString().toUpperCase() + " ";<br />

}<br />

trace(employeeData);<br />

Si la métho<strong>de</strong> toString() n'était pas incluse dans ce co<strong>de</strong> et que la ligne dans la boucle for<br />

utilisait employee[prop].toUpperCase(), la valeur <strong>de</strong> sortie serait "un<strong>de</strong>fined un<strong>de</strong>fined<br />

BOB". L'inclusion <strong>de</strong> la métho<strong>de</strong> toString() pro<strong>du</strong>it la valeur <strong>de</strong> sortie souhaitée :<br />

"284759021 60000 BOB".<br />

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

public toUpperCase() : String<br />

Renvoie une copie <strong>de</strong> l'objet String, avec tous les caractères minuscules convertis en<br />

majuscules. La valeur d'origine n'est pas modifiée.<br />

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

Valeur renvoyée<br />

String - Chaîne.<br />

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

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

Saved successfully!

Ooh no, something went wrong!