我有一个带有2个状态 - “”(即无名称/默认)和“事务处理”的flex组件,以及一组从一个状态转移到另一个状态的转换。Flex中的状态转换
有一个按钮,它调用下面的函数在两种状态之间进行切换时,点击
public function ToggleState():void
{
if (this.currentState=="Transactional")
{
this.currentState = "";
}
else
{
this.currentState = "Transactional";
}
}
一切正常,除非你点击按钮,而该组件是从一个状态变化到另一个。之后,事情开始变得奇怪 - 一些以前会淡出的组件不再消失。其他不再重新出现
我怀疑这是因为转换没有正确完成,因此正在动画组件的属性没有正确重置为正确的值。
我试图把一些检查,以判断是否状态改变(因此禁用按钮而转换被打),但唯一的事件,我能找到监听是
enterState
currentStateChange
currentStateChanging
所有的在转换完成之前被触发。
有没有人知道任何其他合适的事件来倾听或更好的方式做状态改变?
UPDATE:
这里是我使用的过渡
<transitions>
<mx:Transition fromState="" toState="Transactional">
<mx:Sequence>
<mx:Parallel>
<mx:AnimateProperty target="{Controller}" property="y" fromValue="-60" toValue="-1" duration="600" />
<mx:AnimateProperty target="{Environment}" property="y" fromValue="156" toValue="46" />
<mx:AnimateProperty target="{ProfitAndLoss}" property="y" fromValue="156" toValue="126" />
<mx:AnimateProperty target="{Summary}" property="y" fromValue="156" toValue="56" />
<mx:AnimateProperty target="{Assets_Container}" property="x" fromValue="266" toValue="246" />
<mx:AnimateProperty target="{Liabilities_Container}" property="x" fromValue="425" toValue="505" />
<mx:Fade target="{TransactionalBackgroundImage}" alphaFrom="0" alphaTo="1" />
</mx:Parallel>
<mx:AnimateProperty target="{Summary}" property="x" fromValue="42" toValue="256" />
</mx:Sequence>
</mx:Transition>
<mx:Transition fromState="Transactional" toState="">
<mx:Sequence>
<mx:AnimateProperty target="{Summary}" property="x" fromValue="256" toValue="42" />
<mx:Parallel>
<mx:AnimateProperty target="{Controller}" property="y" fromValue="-1" toValue="-60" />
<mx:AnimateProperty target="{Environment}" property="y" toValue="156" fromValue="46" />
<mx:AnimateProperty target="{ProfitAndLoss}" property="y" toValue="156" fromValue="126" />
<mx:AnimateProperty target="{Summary}" property="y" toValue="156" fromValue="56" />
<mx:AnimateProperty target="{Assets_Container}" property="x" fromValue="246" toValue="266" />
<mx:AnimateProperty target="{Liabilities_Container}" property="x" fromValue="505" toValue="425" />
<mx:Fade target="{TransactionalBackgroundImage}" alphaFrom="0" alphaTo="0" />
</mx:Parallel>
</mx:Sequence>
</mx:Transition>
</transitions>
嗨,谢谢你的回应。 我正在定义mxml不是动作的转换。我已经发布了转换的mxml。我将尝试在改变状态之前查看是否可以在每个效果上调用end()方法。谢谢 – Addsy 2010-01-11 17:14:16
对我来说这看起来很干净,除了最后一个没有执行任何操作的Fade实例:alphaFrom =“0”alphaTo =“0”。 – Simon 2010-01-11 17:27:55
啊哎呀!感谢您指出了这一点!不幸的是,你所建议的方法意味着过渡很早就完成了 - 我尝试过,但是他们需要完成的权力才是完成的。你把我放在解决方案的吐出距离之内 - 还有其他的元素会在状态改变时简单地消失并出现 - 也就是说没有过渡只是将可见设置为假。这些属性会立即更新,以便我可以使用它们来测试是否可以执行其他状态更改。因为如果没有你的帮助,我不会找到它,我已经接受你的答案。非常感谢 – Addsy 2010-01-11 18:01:17