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.
- flash.globalization: Flash Player built-in
- mx.formatters: Flex SDK MX namespace
- 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
|Flash Player 9
|Flash Player 10.1
|Date time formatter||Yes||Yes||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 inheritance||N/A||No||Yes|
- flash.globalization package document
- Flex SDK mx.formatters package document
- Flex SDK mx.validators package document
- Flex SDK Hero (Beta) spark.globalization package document
- Flex SDK Hero (Beta) spark.formatters package document
- Flex SDK Hero (Beta) spark.validators package document (Not yet available as of the writing)