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 />

}<br />

if(status == LastOperationStatus.USING_FALLBACK_WARNING)<br />

{<br />

trace("Warning - Fallback locale ID used by "<br />

+ serviceName + ": " + localeID);<br />

}<br />

else if (status == LastOperationStatus.UNSUPPORTED_ERROR)<br />

{<br />

trace("Error in " + serviceName + ": " + status);<br />

//abort application<br />

throw(new Error("Fatal error", 0));<br />

}<br />

else<br />

{<br />

trace("Error in " + serviceName + ": " + status);<br />

}<br />

}<br />

else<br />

{<br />

trace(serviceName + " created for locale ID: " + localeID);<br />

}<br />

First the setLocale() method creates a LocaleID object. This object makes it easier to get details about the actual locale<br />

later, if needed.<br />

Next it creates new NumberFormatter, Curr<strong>en</strong>cyFormatter, and DateTimeFormatter objects for the locale. After<br />

creating each formatter object it calls the traceError() method. This method displays error and warning messages in<br />

the console if there is a problem with the requested locale. (A real application should react based on such errors rather<br />

than just tracing them).<br />

After creating the Curr<strong>en</strong>cyFormatter object, the setLocale() method sets the formatter’s curr<strong>en</strong>cy ISO code, curr<strong>en</strong>cy<br />

symbol, and fractionalDigits properties to previously determined values. (Those values are set each time the user<br />

selects a new market from the Markets combo box).<br />

After creating the DateTimeFormatter object, the setLocale() method also retrieves an array of localized month name<br />

abbreviations.<br />

Formatting the data<br />

The formatted stock data is pres<strong>en</strong>ted in a DataGrid control. The DataGrid columns each call a label function that<br />

formats the column value using the appropriate formatter object.<br />

In the Flash version, for example, the following code sets up the DataGrid columns:<br />

Last updated 6/6/2012<br />

953

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

Saved successfully!

Ooh no, something went wrong!