下面是一个非常简单的例子,随机地,如果我点击step2按钮,状态将改变,但Step 2面板将不在那里。
我怀疑由于某种原因没有创建状态的子级,这就是我将itemCreationPolicy设置为"immediate“的原因,但这没有什么区别
这对应用程序来说是灾难性的,因为用户处于不确定状态并被迫刷新
有什么想法吗?
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationPolicy="all" currentState="step1">
<s:states>
<s:State name="step1"/>
<s:State name="step2"/>
</s:states>
<s:BorderContainer includeIn="step1" itemCreationPolicy="immediate">
<s:Panel title="Step 1"/>
</s:BorderContainer>
<s:BorderContainer includeIn="step2" itemCreationPolicy="immediate">
<s:Panel title="Step 2"/>
</s:BorderContainer>
<s:Button title="step1" click="{this.setCurrentState('step1',true)}"/>
<s:Button title="step2" click="{this.setCurrentState('step2',true)}"/>
</s:BorderContainer>发布于 2010-11-19 17:09:28
我刚刚用Flex SDK 4.1测试了它,它可以在不改变创建策略的情况下工作。单击"step 2“成功更改状态。
顺便说一句:你不需要在点击事件处理程序中使用大括号...
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" currentState="step1">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:states>
<s:State name="step1"/>
<s:State name="step2"/>
</s:states>
<s:BorderContainer includeIn="step1">
<s:Panel title="Step 1"/>
</s:BorderContainer>
<s:BorderContainer includeIn="step2">
<s:Panel title="Step 2"/>
</s:BorderContainer>
<s:Button label="step1" click="setCurrentState('step1', true)"/>
<s:Button label="step2" click="setCurrentState('step2', true)"/>
</s:Application>发布于 2010-11-19 22:15:34
似乎您使用的是旧的/预发布版本的Flex4SDK。更新到4.1.0 -最新的稳定版本可能是个好主意。
附言:编写this.setCurrentState('step1',true)不是最好的主意。我建议使用currentState = 'step1' --这是状态改变的官方方式。
https://stackoverflow.com/questions/4223176
复制相似问题