incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Left Right <olegsivo...@gmail.com>
Subject Re: Flex and names spaces in MXML
Date Fri, 16 Mar 2012 10:59:52 GMT
Justin,

Unfortunately, you have to already tell the compiler what namespace to use
on the root node. This is because the system has already been built wrong.

Second, I don't think this is a very good idea in general, and especially
not if it should be handled by MXMLC code. This approach created a lot of
problems and fundamental confusions about MXML in the past. MXML is a
template. What you now put as a default (Application) may not even exist in
the project that uses MXML. So, if you want to keep this template generic,
you need a way to show in the template itself, what is the origin of the
class that is being used.
Due to the documentation and suggested workflows, there is an impression
that MXML is exclusively used with mx or spark or derived components, while
there is no such connection. The code below is absolutely valid MXML (at
least as of version < 4 of SDK):

<flash:Sprite xmlns:flash="flash.display.*">
  <flash:enterFrame>
    super.removeEventListener(Event.ENTER_FRAME, arguments.callee);
    trace("This is a no-Flex MXML");
  </flash:enterFrame>
</flash:Sprite>

In later version you'd need to specify the namespace for flex framework you
are "targeting" even though it targets none... well, reason has never been
a strong side of MXML. :)

Now imagine you decided to put framework code forcefully into default
namespace - you prevented everyone from using that namespace even though
they might not be using the framework. I would see how putting things,
which are unquestionably present and will likely remain so in a long time,
into default namespace - the top-level Flash classes seem to be good
candidates. Classes from flash.* packages aren't, because there's no
analogue in JavaScript, and if you want to crosscompile to JavaScript,
you'll find it to be a problem. All the mx, spark, flashx, com.adobe and
similar - are just extensions, and it should be clear to anyone using the
tool.

On a somewhat different note, MXML being an XML variant has to adhere to
XML rules, so, the code you wrote isn't valid. XML is a very bad choice for
designing programming language templates, but reason has never been a
strong side of MXML. (does it sound familiar yet? :)) So that's why, unlike
in AS, you will have to declare the prefix you are using with the node name
in the ancestor tag of the tag that is using it. You cannot really avoid
doing it because of the tools that work with MXML are built on top of tools
that work with XML, and if MXML breaks some basic XML rules, the tools will
stop working.

The only reason for using MXML, really, is that there are tools for working
with XML, so you have prerequisites. But, really, if anyone was about to
break the compatibility with XML, then there's no point in using lots of
other things imposed by XML. Maybe it would be better to take RTF or LaTeX
as a pattern... maybe YAML, or, oh horror, s-expressions! :)

Best.

Oleg

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message