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.

Exemple<br />

L'exemple suivant utilise la propriété autoReplace et la métho<strong>de</strong> addDelayedInstance()<br />

pour renseigner une champ <strong>de</strong> texte sur la scène avec la chaîne IDS_GREETING provenant <strong>du</strong><br />

fichier <strong>de</strong> langue XML anglais.<br />

import mx.lang.Locale;<br />

greeting_txt.autoSize = "left";<br />

Locale.autoReplace = true;<br />

Locale.addDelayedInstance(greeting_txt, "IDS_GREETING");<br />

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

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

statique publique addXMLPath(langCo<strong>de</strong>:String, path:String) : Void<br />

Ajoute la paire {languageCo<strong>de</strong> et languagePath} dans le tableau interne en vue d'une<br />

utilisation ultérieure. Flash procè<strong>de</strong> généralement ainsi lorsque la métho<strong>de</strong> <strong>de</strong> remplacement<br />

<strong>de</strong>s chaînes est définie sur "automatically at runtime" ou "via <strong>ActionScript</strong> at<br />

runtime".<br />

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

Paramètres<br />

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

path:String - Le chemin <strong>du</strong> fichier XML à ajouter.<br />

Exemple<br />

L'exemple suivant utilise la métho<strong>de</strong> setInterval() afin <strong>de</strong> vérifier si le fichier <strong>de</strong> langue<br />

XML a été chargé avec succès.<br />

import mx.lang.Locale;<br />

Locale.setLoadCallback(localeCallback);<br />

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

// create interval to check if language XML file is loa<strong>de</strong>d<br />

var locale_int:Number = setInterval(checkLocaleStatus, 10);<br />

function checkLocaleStatus():Void {<br />

if (Locale.checkXMLStatus()) {<br />

clearInterval(locale_int);<br />

trace("clearing interval @ " + getTimer() + " ms");<br />

}<br />

}<br />

// callback function for Locale.setLoadCallback()<br />

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

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

}<br />

Locale (mx.lang.Locale) 757

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

Saved successfully!

Ooh no, something went wrong!