我的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>
答案 0 :(得分:1)
解决方案是使用explicitHeight属性而不是height。这是因为height是Flex使用的特殊属性符号。
来自SetProperty PSEUDONYMS属性:
/**
* @private
* This is a table of pseudonyms.
* Whenever the property being overridden is found in this table,
* the pseudonym is saved/restored instead.
*/
private static const PSEUDONYMS:Object =
{
width: "explicitWidth",
height: "explicitHeight",
currentState: "currentStateDeferred"
};
因此,如果你设置了高度,那么它实际上是设置的explicitHeight。请记住另一个名为RELATED_PROPERTIES的相关属性。它包含有关百分比宽度和高度以及显式宽度和高度信息的其他数据。
有关更多信息,请参阅mx.states.SetProperty。
为了解决这个问题,我们改变了这个:
<s:SetAction target="{this}" property="height"/>
对此:
<s:SetAction target="{this}" property="explicitHeight"/>