Namespaces for Spark, MX, and MXML 2009

This paper proposes some changes to the flex framework's default mapping from XML namespace and tagname to actionscript classname.

Updated: 12/07/2009. This topic is now obsolete. It was replaced by the ARB item Dropping the Fx Prefix.

In summary:

"http://ns.adobe.com/mxml/2009"
Flex SDK 4 introduced MXML 2009 as a separate language namespace.

Component libraries are in their own namespace. There are two standard component libraries in the Flex SDK:

"library://ns.adobe.com/flex/mx"
Contains the MX components that were also in Flex 3 (and by default had the halo theme applied).

"library://ns.adobe.com/flex/spark"
Contains the Spark components which are new to Flex 4.


h2. Obsolete Sections Retained Below

h3. Decision (accurate up to 2/1/2009, community requests re-opening)

# The MXML 2009 namespace "http://ns.adobe.com/mxml/2009" will contain ALL the classes that Adobe recommends for use in MXML 2009 documents, including but not limited to: all Spark UI components, all Halo UI components (including Halo components like Button that have a Spark equivalent like FxButton), Graphics tags, effects, basic data types, Flash graphics classes, AIR filesystem classes, formatters and validators, charts, data classes, and RPC classes. Users working with the MXML 2009 language should never need to use any namespace other than 2009 in order to work with the standard 2009 component set.
# Similarly, the MXML 2006 namespace "http://www.adobe.com/2006/mxml" will contain ALL the classes that Adobe recommends for use in MXML 2006 documents. This will be (more-or-less) the same set of components that were available in this namespace in Flex 3
# The namespaces "library:adobe/flex/gumbo" and "library:adobe/flex/halo" are no longer necessary, since (a) all halo components are available in the 2006 namespace, and (b) all gumbo components, and all 2009-compatible halo components, are available in the 2009 namespace.

The outstanding action item is to modify the manifests of the various Flex 4 SWCs to implement the above decision.

It's worth noting that it is possible to merge all 2009-compatible components into a single namespace because the ARB has decided that there will be no duplicate names between halo and gumbo components (e.g. Halo has a Button component, Gumbo will have FxButton).

h3. Earlier comments, status, and proposals

The remainder of this document contains earlier writings on this issue, which are now out-of-date. They are included here for reference.

h4. Status

There are still outstanding questions:
* is it really our goal to have a single namespace for everything. Some feel that it's ok to have multiple namespaces, the tool can take care of this. Others feel that multiple namespaces make source code harder to work with.
* how much work should users have to do to upgrade from Flex 3 to Flex 4, or from Flex 4 to Flex 4.5. How well should we support developers who have Flex 3 apps and want to start using Flex 4 bit-by-bit?

The "Class Prefix" ARB issue, which is still pending, relates to the namespaces issue.

Based on the above, the Namspace issue is on hold until the Class Prefix issue has been addressed.

h3. Background

When the MXML compiler is compiling a tag like:

<foo:Button  xmlns:foo="abcdef" ...>

it needs to do a lookup to find out that "Button" in the "abcdef" namespace maps to a certain class. The lookup is based on data from 2 different places.
# the <namespaces> section of the config file (e.g. flex-config.xml), which references various manifest files.
# the catalog.xml inside each SWC of the library path, which is based on a manifest file.

The mappings currently in Flex 4 define the following namespaces:
|| Namespace || Purpose |
| http://ns.adobe.com/mxml/2009 | MXML/2009 Language tags + Gumbo components + FXG tags |
| library:adobe/flex/gumbo | Gumbo components |
| http://ns.adobe.com/fxg/2008 | all FXG tags |
| http://www.adobe.com/2006/mxml | MXML/2006 language tags + Halo components |
| http://library:adobe/flex/halo | halo components |

For each namespace, there is a (long!) list of actionscript classes. See the manifest files in <SDK>/frameworks/ and <SDK>/frameworks/projects/* for details.

h3. Proposed changes

The proposed changes affect which classes are available in the MXML/2009 namespace. We do not propose adding or removing any namespaces. All the proposed changes affect MXML/2009 only. All the proposed changes would be implemented by adding data to mxml-2009-manifest.xml.

Three sets of changes are proposed...

h4. 1. Add missing basic classes to MXML/2009

The MXML 2006 namespace contains a few key building-block classes that are not defined in MXML/2009:
* basic data types
** <component id="RegExp" class="RegExp" lookupOnly="true"/>
* Flash graphics classes
** <component id="Matrix" class="flash.geom.Matrix" lookupOnly="true"/>
** <component id="Point" class="flash.geom.Point" lookupOnly="true"/>
** <component id="Sprite" class="flash.display.Sprite" lookupOnly="true"/>
* Modules
** <component id="Module" class="mx.modules.Module"/>
** <component id="ModuleLoader" class="mx.modules.ModuleLoader"/>

I propose these be added to the MXML 2009, for completeness.

h4. 2. Add all effects to MXML/2009

Currently the MXML/2009 namespace contains only those effects in the flex.effects.* package. However, there are many more effects defined in MXML/2006 in the mx.effects.* package, for example Dissolve, Parallel, Zoom, etc. I believe all these effects work in Flex 4, and there are no plans to do major revisions. So it makes sense to include all the effects in the MXML/2009 namespace.

h4. 3. Add new categories of classes to MXML/2009

The MXML 2009 namespace as currently defined contains only UI-related components. By contrast, the MXML 2006 namespace included many types of components, not just UI components. These additional categories are
* Air filesystem classes
* Formatters and validators
* Charts
* Data classes (e.g. ListCollectionView)
* RPC classes (e.g. RemoteObject or WebService)

When a developer is creating a Flex 4 app, they will need to use the 2009 namespace for their UI tags, and the halo namespace for tags in these other categories. This creates the impression that MXML/2009 is a set of deltas from the 'main flex base' (which is MXML/2006).

I propose that we want Flex 4 users to think of MXML/2009 as s complete set of clasess. To do this, we need to add all the non-UI categories of classes - Formatters, Validators, Data classes, etc - to the MXML/2009 namespace.

h4. 4. Add current Halo components to MXML/2009

Once recommendations 1-3 above are implemented, the only time you'll need to use a non-default namespace in an MXML2009 document is to get access to Halo UI components. To minimize the necessity of this, the proposal is to include in the MXML/2009 namespace all the halo components that do not have a Gumbo namespace.

When all recommendations 1-4 are implemented, MXML/2009 will be s complete set of clasess, and developers can build complete apps in Flex 4 using exclusively the MXML/2009 namespace.