Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Later
-
Adobe Flex SDK Previous
-
None
-
None
-
Affected OS(s): All OS Platforms
Affected OS(s): All OS Platforms
Browser: Firefox 2.x
Language Found: English
Description
I really dislike how styles and events are kind of merged into the MXML syntax, to look like properties. It means that you can't have a property with the same name as an event or a style.
I'd like it if there were extra namespaces added, that represented styles and events:
<mx:Button event:click="onClick()" style:color="#000000" />
Advantages:
1. Easier for a parser (e.g. in an editor) to differentiate between styles, events and properties
2. Clearer sytax
3. Reduces chance of conflicts
4. Allows styles and events to be added to objects that did not declare it with metadata, e.g. for inherited styles or events that are triggered on an object from outside.
Disadvantages:
1. A bit extra typing (though a good editor should negate this)
2. Some loss of backwards compatibility (but should be relatively easy to migrate, since errors will be reported at compile time)
For backwards compatibility with existing code, there could be a compiler flag that makes it optional.
This mechanism could be implemented generically enough so that users could define other namespaces, that allow meta information to be set on objects in mxml without that object having to support it by extending a base class or implementing the interface.
For example, this annotates an object with contextual help text:
<MyView id="myView" xmlns:help="foo.com/help" help:text="Use this screen to change your settings." />
Elsewhere you would retrieve the value with code something like:
namespace help="foo.com/help";
helpText = MetaRegistry.getRegistry(help, myView).getValue("text");
Other usages could be to write custom layout engines or to extend MXML in a way similar to how Spry extens HTML.