我想了解如何使Flex转换以具有吸引力的流畅方式运行。没有他们显得非常波涛汹涌,我无法让他们工作。无法使Flex转换行为顺利
我附上了一个愚蠢的演示应用程序来说明这一点。它显示了一个具有自定义ItemRenderer的List。当列表中的项目被选中时,TextInput应该慢慢变大。 当一个项目被取消选择时,TextInput应该慢慢收缩。
这个实现有2个问题,使它看起来很丑。这些可以通过在列表上点击来使项目变成动画。这些问题是:
当一个项目动画但进入“悬停”状态时,TextInput快速恢复为小尺寸。为什么是这样?
当某个项目的动画被打断时,它将捕捉到最大或最小大小,然后开始动画,而不是从当前值继续动画。为什么?
任何帮助非常感谢。
感谢, 菲尔 TestApplication.mxml
<?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"
initialize="init(event)"
minWidth="900" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
protected function init(event:FlexEvent):void {
var ac:ArrayCollection = new ArrayCollection();
ac.addItem("A1");
ac.addItem("B2");
ac.addItem("C3");
myList.dataProvider = ac;
}
]]>
</fx:Script>
<s:List id="myList" width="410" height="350" itemRenderer="MyItemRenderer" requireSelection="true"/>
</s:Application>
MyItemRenderer.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
</s:states>
<s:transitions>
<s:Transition fromState="*" toState="selected" id="itemHasBeenSelected" >
<mx:AnimateProperty property="width" toValue="300" duration="3000" target="{textInput}" />
</s:Transition>
<s:Transition fromState="selected" toState="*" id="itemHasBeenUnselected">
<mx:AnimateProperty property="width" toValue="100" duration="3000" target="{textInput}" />
</s:Transition>
</s:transitions>
<s:Group width="100%">
<s:Label text="{data}" color.selected="red" color.normal="black"/>
<s:TextInput x="100" id="textInput" width="100"/>
</s:Group>
</s:ItemRenderer>
该解决方案的作品,感谢和动画看起来非常顺利。我不知道autoReverse是一个非常好的功能。对于失去悬停状态感到羞耻,因为在我的真实应用程序中,“悬停”和“选定”状态显示关闭按钮。 – Phil
作为一个附加的“额外”,我不是Adobe的运动类的粉丝,并会推荐你看看[TweenMax](http://www.greensock.com/tweenmax/)。 –
是的,我自己,我无法让这三个州在Adobe框架中一起工作。我并不是说这是不可能的,但J_A_X是正确的,通过使用其他工具或手动处理鼠标事件,可以使所有三个状态顺利地在彼此之间转换。 – merv