我的 Spark 组件上有一个过渡设置。从状态 1 到状态 2 的变化之一是高度的变化。该值立即得到应用。这是我的代码:
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
height="200" height.state2="400">
<s:states>
<s:State name="state1"/>
<s:State name="state2"/>
</s:states>
<s:transitions>
<s:Transition fromState="state1" toState="state2" >
<s:Sequence duration="2000" >
<s:Rotate3D target="{this}"
angleYFrom="0" angleYTo="90"
startDelay="0"
suspendBackgroundProcessing="true"
autoCenterTransform="true" />
<s:SetAction target="{this}" property="height"/>
<s:Rotate3D target="{this}"
angleYFrom="-90" angleYTo="0"
startDelay="0"
suspendBackgroundProcessing="true"
autoCenterTransform="true" />
</s:Sequence>
</s:Transition>
</s:transitions>
<s:Rect width="100%" height="100%" >
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Rect>
</s:Group>
然后在我的主应用程序中:
<?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"
minWidth="955" minHeight="600" xmlns:local="*"
>
<local:MyGroup id="group" verticalCenter="0" horizontalCenter="0" width="400"/>
<s:Button label="Change states" click="group.currentState=group.currentState=='state1'?'state2':'state1';"/>
</s:Application>