2010-05-11 54 views
0

我想写一个转换,其中State1的所有元素围绕Y轴旋转,然后显示来自State2的元素 下面的虚拟代码中说明了这些(假设标签1是一个组) 。当元素被删除时的状态转换

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx"> 
<s:states> 
    <s:State name="State1"/> 
    <s:State name="State2"/> 
</s:states> 
<s:transitions> 
    <s:Transition fromState="*" toState="State2" autoReverse="true"> 
    <s:Rotate3D target="{label2}" angleYFrom="-90" angleYTo="0" autoCenterTransform="true" duration="1000"/> 
    </s:Transition> 
</s:transitions> 
<fx:Declarations> 
    <s:Rotate3D id="phaseOut" target="{label1}" angleYFrom="0" angleYTo="90" autoCenterTransform="true" duration="1000" effectEnd="currentState='State2'" /> 
</fx:Declarations> 
<s:Label id="label1" includeIn="State1" text="This is state 1" horizontalCenter="0" verticalCenter="0"/> 
<s:Label id="label2" includeIn="State2" text="This is state 2" horizontalCenter="0" verticalCenter="0"/> 
<s:Button label="Change" horizontalCenter="0" verticalCenter="30" click.State1="phaseOut.play()" click.State2="currentState='State1'"/> 
</s:WindowedApplication> 

我的第一个问题是被调用的状态转变时,从状态1的所有元素都已经走了,所以我必须一分为二黑客的过渡(参见“淘汰”) 这似乎真的很差,因为我基本上重写过渡机制。
Q1:是否有一种“干净”的方式来过渡不属于State2的元素?

第二个问题是当您恢复到状态1时,元素已被旋转。
Q2:动画中是否存在“autoReverse”这样的事物?

感谢您的时间!

回答

0

使用viewstacks似乎很好做的伎俩:

<?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" > 
    <fx:Declarations> 
     <s:Rotate3D id="phaseOut" angleYFrom="0" angleYTo="90" duration="500" autoCenterTransform="true" /> 
     <s:Rotate3D id="phaseIn" angleYFrom="-90" angleYTo="0" duration="500" autoCenterTransform="true" startDelay="500" /> 
    </fx:Declarations> 
    <mx:ViewStack id="viewstack1" width="200" height="200" horizontalCenter="0" verticalCenter="0"> 
     <s:NavigatorContent label="View 1" width="100%" height="100%" hideEffect="{phaseOut}" showEffect="{phaseIn}" > 
      <s:Label id="label1" text="This is state 1" horizontalCenter="0" verticalCenter="0"/> 
     </s:NavigatorContent> 
     <s:NavigatorContent label="View 2" width="100%" height="100%" hideEffect="{phaseOut}" showEffect="{phaseIn}"> 
      <s:Label id="label2" text="This is state 2" horizontalCenter="0" verticalCenter="0"/> 
     </s:NavigatorContent> 
    </mx:ViewStack> 
    <s:Button label="Toggle" click="viewstack1.selectedIndex=(viewstack1.selectedIndex==0?1:0)" horizontalCenter="0" top="10"/> 
</s:Application> 

的代码是整齐的效果exactely如预期

1

您可以添加“删除”过滤器以仅隔离要删除的项目的效果,并使用RemoveChildAction让转换知道何时执行删除项目的操作,而不是执行两个转换。

信息上RemoveChildAction:

http://livedocs.adobe.com/flex/3/langref/mx/effects/RemoveChildAction.html

信息的过滤器: http://livedocs.adobe.com/flex/3/langref/mx/effects/Effect.html#filter

影响已在反向播放反向方法: http://livedocs.adobe.com/flex/3/langref/mx/effects/Effect.html#reverse%28%29

虽然我听说混合来自人们关于它是如何成功的结果。

相关问题