-2

I have 2 buttons on my main page (main.mxml). When i click on btn1 it has to show btn1_main.mxml , and similarly on click of btn2 I want btn2_main.mxml. Both these btn1_main.mxml and btn2_main.mxml are in ./components

I have created event listenteners on the the mouse click for the buttons. Want to know what should i do to open the new page when event handler is executing.

Thanks in advance

1 Answers1

0

There are 2 ways to do this

  1. 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;

  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