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.

languageCo<strong>de</strong>Array (propriété<br />

Locale.languageCo<strong>de</strong>Array)<br />

statique publique languageCo<strong>de</strong>Array : Array [lecture seule]<br />

Un tableau contenant les co<strong>de</strong>s <strong>de</strong> langue <strong>de</strong>s langues ayant été spécifiées ou chargées dans le<br />

fichier FLA. Les co<strong>de</strong>s <strong>de</strong> langue ne sont pas triés par ordre alphabétique.<br />

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

Exemple<br />

L'exemple suivant charge un fichier <strong>de</strong> langue XML en fonction <strong>de</strong> la valeur actuelle d'un<br />

composant ComboBox. Faites glisser un composant ComboBox sur la scène et donnez-lui le<br />

nom d'occurrence lang_cb. A l'ai<strong>de</strong> <strong>de</strong> l'outil Texte, créez un champ <strong>de</strong> texte dynamique et<br />

donnez-lui le nom d'occurrence greeting_txt. Dans le panneau Chaînes, ajoutez au moins<br />

<strong>de</strong>ux langues actives, définissez l'option <strong>de</strong> remplacement <strong>de</strong>s chaînes sur "via<br />

<strong>ActionScript</strong> at runtime", puis cliquez sur OK. Ensuite, ajoutez l'ID <strong>de</strong> chaîne <strong>de</strong><br />

IDS_GREETING, puis entrez <strong>du</strong> texte pour chaque langue active. Enfin, ajoutez le co<strong>de</strong><br />

<strong>ActionScript</strong> suivant à l'image 1 <strong>du</strong> scénario principal :<br />

import mx.lang.Locale;<br />

Locale.setLoadCallback(localeListener);<br />

lang_cb.dataProvi<strong>de</strong>r = Locale.languageCo<strong>de</strong>Array.sort();<br />

lang_cb.addEventListener("change", langListener);<br />

function langListener(eventObj:Object):Void {<br />

Locale.loadLanguageXML(eventObj.target.value);<br />

}<br />

function localeListener(success:Boolean):Void {<br />

if (success) {<br />

greeting_txt.text = Locale.loadString("IDS_GREETING");<br />

} else {<br />

greeting_txt.text = "unable to load language XML file.";<br />

}<br />

}<br />

loadLanguageXML (métho<strong>de</strong><br />

Locale.loadLanguageXML)<br />

statique publique loadLanguageXML(xmlLanguageCo<strong>de</strong>:String,<br />

customXmlCompleteCallback:Function) : Void<br />

Charge le dossier <strong>de</strong> langue XML spécifié.<br />

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

Locale (mx.lang.Locale) 761

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

Saved successfully!

Ooh no, something went wrong!