我有一个视图,其中定义了所有状态:
<s:Group xmlns="...." currentState="default">
<s:states>
<s:State name="default" stateGroups="state1,state2" />
<s:State name="custom" />
</s:states>
<s:Label text="Custom" text.state1="Item 1" />
<s:Label text="Custom" text.state2="Item 2" />
</s:Group>
当视图加载时(使用currentState =='default'),标签显示:
Item 1
Item 2
当它切换到'custom'时:
Custom
Custom
这是预期的。现在,我想改变'自定义'状态,以便它包含stateGroup'state1'。
我已经通过将新值推送到'自定义'stateGroups来更改'自定义'状态,但这不起作用,所以......
我已将“自定义”状态替换为:
this.states [1] = new State({name:'custom',stateGroups:['state1']});
在反省了视图后,我发现'custom'状态现在在stateGroup属性中有一个'state1'。
这里存在问题,当切换到'自定义'状态时,第一个标签仍然显示'自定义',而不是预期的'第1项'。如果我将'state1'添加到'custom'并重新编译,它就可以正常工作。
那么是否有人提示强制视图重新读取状态并正确绘制视图?
谢谢,迈克尔