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.

setString (métho<strong>de</strong> Locale.setString)<br />

statique publique setString(stringID:String, languageCo<strong>de</strong>:String,<br />

stringValue:String) : Void<br />

Définit la nouvelle valeur <strong>de</strong> chaîne d'un ID <strong>de</strong> chaîne et d'un co<strong>de</strong> <strong>de</strong> langue spécifiés.<br />

Disponibilité : <strong>ActionScript</strong> <strong>2.0</strong> ; Flash Player 8<br />

Paramètres<br />

stringID:String - Le numéro d'i<strong>de</strong>ntification (ID) <strong>de</strong> la chaîne à définir.<br />

languageCo<strong>de</strong>:String - Le co<strong>de</strong> <strong>de</strong> langue.<br />

stringValue:String - Une valeur <strong>de</strong> chaîne.<br />

Exemple<br />

L'exemple suivant utilise la métho<strong>de</strong> setString() pour définir la chaîne IDS_WELCOME <strong>de</strong>s<br />

langues Anglais (en) et Français (fr).<br />

import mx.lang.Locale;<br />

Locale.setString("IDS_WELCOME", "en", "hello");<br />

Locale.setString("IDS_WELCOME", "fr", "bonjour");<br />

trace(Locale.loadStringEx("IDS_WELCOME", "en")); // hello<br />

stringIDArray (propriété Locale.stringIDArray)<br />

statique publique stringIDArray : Array [lecture seule]<br />

Un tableau contenant tous les ID <strong>de</strong> chaîne <strong>du</strong> fichier FLA. Les ID <strong>de</strong> chaîne ne sont pas triés<br />

par ordre alphabétique.<br />

Disponibilité : <strong>ActionScript</strong> <strong>2.0</strong> ; Flash Player 8<br />

Exemple<br />

L'exemple suivant présente la propriété Locale.stringIDArray <strong>du</strong> fichier <strong>de</strong> langue XML<br />

actuellement chargé. Dans le panneau Chaînes, cliquez sur le bouton Paramètres pour ouvrir<br />

la boîte <strong>de</strong> dialogue Paramètres. Ensuite, ajoutez <strong>de</strong>ux langues actives : Anglais (en) et Français<br />

(fr), définissez le bouton radio <strong>de</strong> remplacement <strong>de</strong>s chaînes sur "via <strong>ActionScript</strong> at<br />

runtime", puis cliquez sur OK. Dans le panneau Chaînes, ajoutez l'ID <strong>de</strong> chaîne <strong>de</strong><br />

IDS_GREETING, puis ajoutez <strong>du</strong> texte pour chaque langue active.<br />

import mx.lang.Locale;<br />

Locale.setLoadCallback(localeCallback);<br />

Locale.loadLanguageXML("fr");<br />

function localeCallback(success:Boolean) {<br />

trace(success);<br />

trace(Locale.stringIDArray); // IDS_GREETING<br />

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

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

Saved successfully!

Ooh no, something went wrong!