tags:

views:

96

answers:

1

Hi guys,

I'm new to flex. Now I'm writing an flex application. I plan to split my application into some MXML files(Application as the root tag). How can I switch from one mxml to another?

BTW, what is the best practice for design large flex application? Just one MXML Application and many MXML component or many MXML Application?

Thanks!

+2  A: 

Hi Yousui, Its always advisable to create application with many mxml files. that will allow to modularize the application. you will be anyway have one main application file and many sub mxml files, which you will add as children to the main app file. splitting application into sub files will keep your code short for each file and development becomes faster. when the file size increases flex builder performance downgrades. also modularising of code will reduce the end swf file size as well the time required to load the application.

you can have one main application file and include the child mxml components like the following.

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    backgroundColor="white" 
    xmlns:components="components.*">
    <mx:HBox width="100%" height="100%" left="10" right="10" top="10" bottom="10">
        <mx:VBox width="100%" height="100%">

            <components:component1 id="comp1"/>

            <components:component2 id="comp2"/>         
        </mx:VBox>
        <components:component3 id="comp3"/>
    </mx:HBox> 
</mx:Application>

Here component1, component2 and component3 are three different mxml files and they are stored in the folder 'components' under 'src'. the folder is declared in the namespace 'components' in the application root tag. this is how you can include the child components using mxml. for including using actionscript you can use the method 'addChild'.

Cheers, PK

Anoop