0

我创建了一个有 5 个状态的主类:

    <s:State name="loginState" />

    <s:State name="librariesState"/>

    <s:State name="createState"/>

    <s:State name="profilesState"/>


</s:states>

每个状态都在一个新的 MXML 组件文件中创建,并在主类中调用如下:

    <components:Homepage includeIn="homeState"/>

    <components:LibrariesPage includeIn="librariesState"/>

<components:CreatePage includeIn="createState"/>

<components:ProfilesPage includeIn="profilesState"/>

在 homeState 中,我有三个按钮,通过单击将我带入 librariesState、createState 和 profilesState。我的问题是如何在 Homepage MXML 组件中调用状态视图(在主类中定义)。我试着写了click="currentState='librariesState',但是在Homepage中没有看到状态LibrariesState。如何从MXML组件中的主类中调用状态?

4

2 回答 2

0

我发现:很简单!在组件类中可以使用 this.parentApplication.currentState="createState";

这是可以从组件访问 main 中的每个方法的方式:此 parentApplication.method()

我希望它可以为像我这样的初学者节省时间。

于 2013-10-18T17:06:18.337 回答
0

你确定你需要某种类型的 ViewStack 吗?通常,当您使用 State 时,是因为您希望对同一视图进行相对较小的更改。诸如“adminState”之类的东西与“userState”形成对比;从而在 adminState 中启用某些按钮在 userState 中被禁用或不活动。

于 2013-07-15T05:10:46.133 回答