734
ActionScript classes
Example
The following example uses the
Locale.autoReplace
property to populate the dynamically
created
greeting_txt
text field on the Stage with the contents of the
IDS_GREETING
string
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
"via ActionScript at runtime"
,
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
true
if the XML file is loaded;
false
otherwise.
Availability:
ActionScript 2.0; Flash Player 7
Returns
Boolean
- Returns
true
if the XML file is loaded;
false
otherwise.
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
greeting_txt
text field
instance on the Stage is populated with the
IDS_GREETING
string from the language XML file.
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");
}
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...