ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > Locale (mx.lang.Locale) > autoReplace (Locale.autoReplace property) | |||
public static autoReplace : Boolean
Determines whether strings are replaced automatically after loading the XML file. If set to true, the text replacement method is equivalent to the Strings panel setting "automatically at runtime". This means that Flash Player will determine the default language of the host environment and automatically display the text in that language. If set to false, the text replacement method is equivalent to the Strings panel setting "via ActionScript at runtime". This means that you are responsible for loading the appropriate XML file to display the text.
The default value of this property reflects the setting that you select for Replace strings in the Strings panel dialog box: true for "automatically at runtime" (the default setting) and false for "via ActionScript at runtime".
Availability: ActionScript 2.0; Flash Player 8
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");
|
|
|
|