0
votes

I have created a main class which has got 5 states:

    <s:State name="loginState" />

    <s:State name="librariesState"/>

    <s:State name="createState"/>

    <s:State name="profilesState"/>


</s:states>

Each state is created in a new MXML component file and is called in the main class as following:

    <components:Homepage includeIn="homeState"/>

    <components:LibrariesPage includeIn="librariesState"/>

<components:CreatePage includeIn="createState"/>

<components:ProfilesPage includeIn="profilesState"/>

In homeState I have three buttons which by clicking take me in librariesState, createState and profilesState. My problem is how to call the state view (defined in the main class) in the Homepage MXML component. I tried to write click="currentState='librariesState', but the state LibrariesState is not viewed in Homepage. How can I call a state from the main class in the MXML component?

2

2 Answers

0
votes

Are you sure you need some type of ViewStack instead ? Generally, when you use a State, its because you want relatively small changes for the same view. Something such as an 'adminState' contrasted with a 'userState'; whereby certain buttons are disabled or inactive in the userState are enabled in the adminState.

0
votes

I have discovered: it is very simple! In the component class one can use this.parentApplication.currentState="createState";

This is the way in which every method from main can be accessed from a components: this parentApplication.method()

I hope it can save time for other people who are beginners like me.