There are 2 ways to do this
- Place btn1_main.mxml and btn2_main.mxml in a ViewStack and change the index of viewStack upon button Click.
Example
<mx:ViewSatck width="100%" height="100%" id="vs">
<components:btn1_Main/>
<components:btn2_Main/>
</mx:ViewStack>
Now in btn1 Click Handler --> vs.selectedIndex = 0; and in btn2 click
hanlder--> vs.selectedIndex = 1;
- Place the 2 mxmls in main.mxml and set visible and includeInLayout true whenever the repective button is clicked
Example
<components:btn1_Main id="m1" visible="false" includeInLayout="false"/>
<components:btn2_Main id="m2" visible="false" includeInLayout="false"/>
Now, in btn1 Click Handler --> m1.visible = true;m1.includeInLayout =true; m2.visible = false;m2.includeInLayout =false
Now in btn1 Click Handler --> m1.visible = false;m1.includeInLayout =false; m2.visible = true;m2.includeInLayout =true