以下是我的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="{creation}">
<s:Fade/>
<s:RemoveAction/>
</s:Sequence>
</s:Transition>
</s:transitions>
<comp:create includeIn="create"/>
<comp:edit includeIn="edit"/>
</s:BorderContainer>
在<comp:create includeIn="create"/>
内我点击了一个按钮:this.parent.currentState='edit'
。但由于某种原因,我收到以下错误:
“一个术语未定义且没有属性......”这使我指向this.parent.currentState='edit'
行。谁有什么不对?感谢。
答案 0 :(得分:0)
你可以更好地封装它。
确保您的组件重新调度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>