Flex 4 / Flash 4 添加到当前状态
我在处理 Flex(或 Flash)4 中的状态时遇到了一些困难。假设我的应用程序具有三种状态;默认(基本)状态、状态 1 和状态 2。
状态 1 应始终基于基本状态,这很容易实现。但是,我希望状态 2 基于当前状态(基础状态或状态 1)。我这辈子都无法弄清楚。我尝试将状态 1 的 basedOn 属性设置为“this.currentState”,但这只会使我的浏览器崩溃。
<s:states>
<s:State name="default"/>
<s:State name="state1"/>
<s:State name="state2" basedOn="{this.currentState}"/>
</s:states>
<s:TitleWindow id="configWindow" includeIn="state1" width="250" height="100%" close="configWindow_closeHandler(event)"/>
<s:Panel id="settings" includeIn="state2" width="200" height="200"/>
I am having a little difficulty working with states in Flex (or Flash) 4. Lets say that my application has three states; the default (base) state, state 1, and state 2.
State 1 should always be based on the base state, that's easy enough to accomplish. However, I would like state 2 to be based on the current state (either base or state 1). I can't for the life of me figure it out. I tried setting the basedOn property of state 1 to "this.currentState", but that just crashes my browser.
<s:states>
<s:State name="default"/>
<s:State name="state1"/>
<s:State name="state2" basedOn="{this.currentState}"/>
</s:states>
<s:TitleWindow id="configWindow" includeIn="state1" width="250" height="100%" close="configWindow_closeHandler(event)"/>
<s:Panel id="settings" includeIn="state2" width="200" height="200"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
basedOn 不是可绑定属性,这就是代码中该值不会更改的原因。
理论上,它是一个读/写属性,因此您可以在运行时更改它;但您必须手动执行此操作,可能是在 ActionScript 中。
根据您的代码片段;我不明白你为什么要这样做。一旦你将状态更改为“state2”,你不会进入一个奇怪的循环吗?
basedOn is not a Bindable property, which is why the value isn't changing in your code.
In theory, it is a read/write property so you can change it at runtime; but you'll have to do so manually, probably in ActionScript.
Based on your code snippet; I don't understand why you want to do this. As soon as you change the state to 'state2' wouldn't you enter into a weird loop?