The differences of three globalization packages in Flash platform

This article was originally written in English. Text in other languages was provided by machine translation.

Developers who are looking at the Flex SDK Hero releases noticed that we have three NumberFormatters (and other globalization-related classes) in the Flash Platform. If you’re wondering why, here’s the explanation.

The Flash platform has the following sets of globalization-related classes for different use cases.

  1. flash.globalization: Flash Player built-in
  2. mx.formatters: Flex SDK MX namespace
  3. spark.formatters/validators/globalization: Flex SDK Spark namespace

The flash.globalization package is implemented as native code in the Flash Player. As with other player classes such as Sprite, you link against playerglobal.swc or airglobal.swc to use it. This package is a recent addition to Flash Player. You need Flash Player 10.1 or AIR 2.0 (or newer versions of these) and a corresponding version of playerglobal.swc or airglobal.swc. They utilize the globalization features provided by the underlying operating system rather than using Flex’s ResourceManager. Therefore you can use any locale supported by the OS, not just the locales for which you built your application. However, these player APIs can produce different results on different platforms. For example, a Greek date might get formatted differently on Macintosh, Windows, Android, etc.

The second set of the globalization classes is provided by the Flex SDK and in the MX namespace. Actually, this MX set is the first globalization classes we provided in the Flash platform. The MX globalization classes provide some formatters for such as number, currency, date and so on. These classes use very limited locale information in the ResourceManager. If you want to do Greek formatting, you have to have Greek resource bundles (which Adobe doesn’t currently provide, although it does provide 16 other locales). Also, locale-aware collation and case conversion were not offered by these classes.

The third set of the globalization classes is also provided by the Flex SDK (beginning with version 4.5) and in the Spark namespace. This is our latest addition in terms of globalization classes. This set acts as glue between the flash.globalization features and the Flex SDK. This Flex Spark version has some advantage compared to the built-in Flash Player globalization features. In particular, they are about the compliance with the MXML syntax and the style inheritance. Those are indeed necessary to make the globalization feature as a part of the Flex SDK UI infrastructure.

Here is a summary comparing the three APIs:

Item Flash Player built-in globalization feature Flex  SDK MX globalization feature Flex SDK Spark globalization feature
Namespace flash.globalization mx.formatters and mx.validators spark.globalization, spark.formatters, spark.validators and others
Required minimum Flex SDK version N/A Flex 3 Flex 4.5
Required minimum Flash Player version Flash Player 10.1
AIR 2
Flash Player 9
AIR 1.1
Flash Player 10.1
AIR 2
Number formatter Yes Yes Yes
Currency formatter Yes Yes Yes
Date time formatter Yes Yes Yes
Number validator No Yes Yes
Currency validator No Yes Yes
Collator Yes No Yes
UI support N/A No

Yes

(DataGrid, Sort, SortField)

Supported locales Depends on underlying OS 16 Depends on underlying OS
Use in MXML No Yes Yes
Use in Script Yes Yes Yes
Locale style inheri­tance N/A No Yes

References

  • flash.globalization package document

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/globalization/package-detail.html

  • Flex SDK mx.formatters package document

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/formatters/package-detail.html

  • Flex SDK mx.validators package document

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/validators/package-detail.html

  • Flex SDK Hero (Beta) spark.globalization package document

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/spark/globalization/package-detail.html

  • Flex SDK Hero (Beta) spark.formatters package document

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/spark/formatters/package-detail.html

  • Flex SDK Hero (Beta) spark.validators package document (Not yet available as of the writing)

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/spark/validators/package-detail.html

2 Responses to The differences of three globalization packages in Flash platform

  1. Florian says:

    Great summary! This is really a big step forward for localized applications, thanks for that.

    As a side note, I think Flash Player 10.2 and not 10.1 is required for Flex 4.5 SDK

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>