Everytime when I type in a MXML code, Flex is going to render
them immediately onto the screen. If I want to store some MXML code
in a variable and only show them on the screen when I want to, is
Right now, I only know I could do that in Actionscript but it
would be nice if I could do it directly in MXML instead of
declaring the VBox, Buttons, etc in Actionscript to store in a
MXML code is compiled into action script from the compiler.
The only way I could see this working would be if you stored MXML
code in separate files or in the database. You would request them
through a backend process that would compile them into a separate
swf, then send them onto the client as another library.
It sounds like you believe that MXML is compiled code. It's
really like a 4GL representation of code, that produces bytecode at
compile-time. Excecpt in the case of MXML, it ends up being
transformed into AS, then compiled into ByteCode executed within
the SWF plugin.
You can create separate components from MXML and then create
AS methods within them to instantiate other components into those
containers. There are various design patterns that you could use to
create colaboration between objects. However, without knowing more
about what you are trying to accomplish, it sounds like you could
look at "States" as the previous writer suggests, or the use of a
ViewStack. Both can be powerful and work well with each other in
showing and hiding Views.