Apache flex 如何更改视图状态?
以下是我的mxml的简化版本:Apache flex 如何更改视图状态?,apache-flex,actionscript-3,Apache Flex,Actionscript 3,以下是我的mxml的简化版本: <s:BorderContainer> <s:states> <s:State name="create"/> <s:State name="edit"/> </s:states> <s:transitions> <s:Transition fromState="create" toState="edit"> <s:Sequence target="{
<s:BorderContainer>
<s:states>
<s:State name="create"/>
<s:State name="edit"/>
</s:states>
<s:transitions>
<s:Transition fromState="create" toState="edit">
<s:Sequence target="{creation}">
<s:Fade/>
<s:RemoveAction/>
</s:Sequence>
</s:Transition>
</s:transitions>
<comp:create includeIn="create"/>
<comp:edit includeIn="edit"/>
</s:BorderContainer>
在
中,我有一个按钮,单击后调用:this.parent.currentState='edit'
。但由于某种原因,我得到了以下错误:
“术语未定义且没有属性…”这将我指向行
this.parent.currentState='edit'
。谁知道怎么了?谢谢。您可以更好地封装它
确保您的组件重新分派click事件,您就可以这样做了,这样做会更好(还有一个好处,就是不必将创建和编辑组件绑定到BorderContainer)
类似于
<s:BorderContainer id="contentHolder">
<s:states>
<s:State name="create"/>
<s:State name="edit"/>
</s:states>
<s:transitions>
<s:Transition fromState="create" toState="edit">
<s:Sequence target="{creation}">
<s:Fade/>
<s:RemoveAction/>
</s:Sequence>
</s:Transition>
</s:transitions>
<comp:create includeIn="create" click="contentHolder.currentstate='edit'"/>
<comp:edit includeIn="edit" click="contentHolder.currentstate='create'"/>
</s:BorderContainer>
您确定[this.parent]指向[]??+1到@adrian吗。我建议在调试模式下运行代码,并查看该行的状态。我们可能需要查看“创建”代码以提供更多帮助。我同意Flextras。请发布所有代码,以便我们也可以调试。有一件事是肯定的:在那一行,下面的一个是空的[this,this.parent,this.parent.currentState]谢谢@Adrian和@Flextras的帮助;问题是我在事件处理程序中移动了[this.parent],因此它不再指向[s:BorderContainer/>]。我莫名其妙地没有立刻抓住它;当我使用两个跟踪命令在调试模式下运行代码后,问题就显而易见了。您可能希望添加解决方案作为问题的答案,以便其他正在搜索相同内容的人会看到您的问题得到了回答并被接受。