tags:

views:

307

answers:

4

Flex newbie question: can MXML be generated on the fly, like HTML is generated by a server?

If yes, is it ok to do so or am I missing an important Flex architectural principle.

+1  A: 

MXML is just a way of describing user interface layout and scripts. This information is then "compiled" into ActionScript, then converted to SWF format for use in the Flash player.

So, yes, you can generate MXML on the fly, in that you can create a text file that contains valid MXML syntax, then use mxmlc to compile it, but there's no way (that I'm aware of) to create MXML and "add" it to your current movie such that the information appears as it would were it compiled.

Michael Todd
+3  A: 

Sort of... but it still needs to be compiled. MXML is not rendered directly, it is first compiled into ActionScript 3.0, and then into a typical SWF... so, you cannot serve your users with MXML. However, like almost all programmming languages, you can use automatic code generation to ease development tasks.

Michael Aaron Safyan
+1  A: 

It is not officially supported but there is a few similar projects doing stuff similar to this.

Should be more as I remember, but can't find it out at this moment... Searching for "MXML runtime dynamic compilation" or something like that should be helpful...

Andy Li
+3  A: 

There is IIS/Apache component given by adobe that can generate your mxml -> html+swf using on the fly compilation, and it also caches the last compiled file.

However its not recommended for bigger projects as it has certain problems that you cant make libraries of your code and organize code accordingly. Namespace usage is very limited.

Akash Kava
More info on that compiler: http://livedocs.adobe.com/flex/3/html/apache_1.html
cliff.meyers