Reputation: 4627
I'm new to Flex and I'm trying to write a program with lots of content in it. There's a sidebar, a main content pane with tabs, etc.
I want to be able to create MXML files (like sidebar.MXML, tab1.mxml, etc.) that I can then load into the sidebar or load into a certain tab. That would make my code a lot more manageable instead of writing all that code inside of the main MXML file.
Can I do this? I have already modularized some of my code by putting them in custom components, but I would really like to be able to load content from other MXML files, much like I can do in PHP:
<?php include 'someFile.php'; ?>
Upvotes: 0
Views: 346
Reputation: 952
The simplest way to do this is just to write custom components, big word for something very easy to do.
Lets say you have your application like this:
Main.mxml
<s:Application ...>
<s:Hgroup id="tabs" ...>
(Your tab content here)
</s:HGroup>
<VGroup id="sideBar" ...>
(Your sidebar content here)
</s:VGroup>
</s:Application>
Then create new mxml files called for example Sidebar.mxml and Tabs.mxml and let them extend from the VGroup and HGroup like this.
Tabs.mxml
<s:HGroup ...>
(Your tab content here)
</s:HGroup>
Sidebar.mxml
<s:VGroup>
(Your sidebar content here)
</s:VGroup>
Then replace the HGroup and VGroup with your custom components in your Main.mxml
Main.mxml
<s:Application xmlns:components="com.the.path.to.your.component.package.*" ...>
<components:Tabs/>
<components:Sidebar/>
</s:Application>
In fact your doing the same thing as:
<?php include 'someFile.php'; ?>
It just looks somewhat different.
Upvotes: 2
Reputation: 1199
You could emulate something like that by compiling the modules into different swfs and loading them as needed, though it is cumbersome and slow.
Upvotes: 2
Reputation: 4627
Okay, it looks like there is no way to do this, other than using custom components.
Upvotes: 1