03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

function langListener(eventObj:Object):Void {<br />

Locale.load<strong>Language</strong>XML(eventObj.target.value);<br />

}<br />

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

if (success) {<br />

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

} else {<br />

greeting_txt.text = "unable to load language XML file.";<br />

}<br />

}<br />

load<strong>Language</strong>XML (Locale.load<strong>Language</strong>XML<br />

method)<br />

public static load<strong>Language</strong>XML(xml<strong>Language</strong>Code:String,<br />

customXmlCompleteCallback:Function) : Void<br />

Loads the specified XML language file.<br />

Availability: <strong>ActionScript</strong> <strong>2.0</strong>; Flash Player 8<br />

Parameters<br />

xml<strong>Language</strong>Code:String - The language code for the XML language file that you want to<br />

load.<br />

customXmlCompleteCallback:Function - Custom callback function to call when XML<br />

language file loads.<br />

Example<br />

The following example uses the load<strong>Language</strong>XML() method to load the English (en) XML<br />

language file. Once the language file loads, the localeCallback() method is called <strong>and</strong><br />

populates the greeting_txt text field on the Stage with the contents of the IDS_GREETING<br />

string in the XML file.<br />

import mx.lang.Locale;<br />

Locale.setLoadCallback(localeCallback);<br />

Locale.load<strong>Language</strong>XML("en");<br />

// create interval to check if language XML file is loaded<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 />

746 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!