Example
The following example loads a language XML file based on the current value of a ComboBox
component. You drag a ComboBox component onto the Stage and give it an instance name
of
. Using the Text tool, you create a dynamic text field and give it an instance name
lang_cb
of
. In the Strings panel, you add at least two active languages, set the replace
greeting_txt
strings radio option to
string ID of IDS_GREETING and enter text for each active language. Finally, you add the
following ActionScript code to Frame 1 of the main Timeline:
import mx.lang.Locale;
Locale.setLoadCallback(localeListener);
lang_cb.dataProvider = Locale.languageCodeArray.sort();
lang_cb.addEventListener("change", langListener);
function langListener(eventObj:Object):Void {
Locale.loadLanguageXML(eventObj.target.value);
}
function localeListener(success:Boolean):Void {
if (success) {
greeting_txt.text = Locale.loadString("IDS_GREETING");
} else {
greeting_txt.text = "unable to load language XML file.";
}
}
loadLanguageXML (Locale.loadLanguageXML
method)
public static loadLanguageXML(xmlLanguageCode:String,
customXmlCompleteCallback:Function) : Void
Loads the specified XML language file.
Availability: ActionScript 2.0; Flash Player 8
Parameters
xmlLanguageCode:String
load.
customXmlCompleteCallback:Function
language file loads.
"via ActionScript at runtime"
- The language code for the XML language file that you want to
- Custom callback function to call when XML
, and click OK. Next, you add a
Locale (mx.lang.Locale)
737
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?