13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Internationalizing applications<br />

The next step is to load and display strings and user interface resources that are specific to the locale. This step can<br />

include tasks such as:<br />

Using the autolayout features to resize the UI to accommodate the string l<strong>en</strong>gths<br />

Choosing the right fonts and supporting font fallbacks<br />

Using the FTE text <strong>en</strong>gine to support other writing systems<br />

Ensuring that input method editors are correctly handled<br />

Checking for errors and fallbacks<br />

The flash.globalization service classes all follow a similar pattern for id<strong>en</strong>tifying errors. They also share a pattern for<br />

falling back from an unavailable requested locale to one that the user’s operating system supports.<br />

The following example shows how to check for errors and fallbacks wh<strong>en</strong> instantiating service classes. Each service<br />

class has a lastOperationStatus property that indicates whether the most rec<strong>en</strong>t method call triggered their errors or<br />

warnings.<br />

var nf:NumberFormatter = new NumberFormatter("de-DE");<br />

if(nf.lastOperationStatus != LastOperationStatus.NO_ERROR)<br />

{<br />

if(nf.lastOperationStatus == LastOperationStatus.USING_FALLBACK_WARNING)<br />

{<br />

// perform fallback logic here, if needed<br />

trace("Warning - Fallback locale ID: " + nf.actualLocaleIDName);<br />

}<br />

else<br />

{<br />

// perform error handling logic here, if needed<br />

trace("Error: " + nf.lastOperationStatus);<br />

}<br />

}<br />

This example simply traces a message if a fallback locale ID is used, or if there is an error. Your application can perform<br />

additional error handling logic, if needed. For example, you could display a message to the user or force the application<br />

to use a specific, supported locale.<br />

Determining the locale<br />

Flash Player 10.1 and later, Adobe AIR 2.0 and later<br />

A locale id<strong>en</strong>tifies a specific combination of language and cultural conv<strong>en</strong>tions for a country or region.<br />

A locale id<strong>en</strong>tifier can be safely managed as a string. But you can use the LocaleID class to obtain additional<br />

information related to a locale.<br />

You create a LocaleID object as follows:<br />

var locale:LocaleID = new LocaleID("es-MX");<br />

After the LocaleID object is created, you can retrieve data about the locale ID. Use the getKeysAndValues(),<br />

getLanguage(), getRegion(), getScript(), getVariant(), and isRightToLeft() methods, and the name<br />

property.<br />

Last updated 6/6/2012<br />

941

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

Saved successfully!

Ooh no, something went wrong!