Example
The following example uses the
created
greeting_txt
in the English XML file. In the Strings panel, click the Settings button to open the Settings
dialog box. You can add two active languages using the Settings dialog box: English (en) and
French (fr), set the replacement strings radio option to
and click OK. Finally, enter a string ID of IDS_GREETING in the Strings panel, and add
text for each active language.
import mx.lang.Locale;
this.createTextField("greeting_txt", 10, 40, 40, 200, 20);
greeting_txt.autoSize = "left";
Locale.autoReplace = true;
Locale.addDelayedInstance(greeting_txt, "IDS_GREETING");
Locale.loadLanguageXML("en");
checkXMLStatus (Locale.checkXMLStatus method)
public static checkXMLStatus() : Boolean
Returns
if the XML file is loaded;
true
Availability: ActionScript 2.0; Flash Player 7
Returns
- Returns
Boolean
true
Example
The following example uses an interval to check every 10 milliseconds to see if the language
file has successfully loaded. Once the XML file has loaded, the
instance on the Stage is populated with the
import mx.lang.Locale;
Locale.setLoadCallback(localeCallback);
Locale.loadLanguageXML("en");
// create interval to check if language XML file is loaded
var locale_int:Number = setInterval(checkLocaleStatus, 10);
function checkLocaleStatus():Void {
if (Locale.checkXMLStatus()) {
clearInterval(locale_int);
trace("clearing interval @ " + getTimer() + " ms");
}
}
// callback function for Locale.setLoadCallback()
function localeCallback(success:Boolean):Void {
greeting_txt.text = Locale.loadString("IDS_GREETING");
}
734
ActionScript classes
Locale.autoReplace
text field on the Stage with the contents of the
false
if the XML file is loaded;
IDS_GREETING
property to populate the dynamically
"via ActionScript at runtime"
otherwise.
otherwise.
false
greeting_txt
string from the language XML file.
string
IDS_GREETING
,
text field
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?