Apache flex 为什么我的身高变化不参与我的状态变化转换?

Apache flex 为什么我的身高变化不参与我的状态变化转换?,apache-flex,flex4,flex-spark,Apache Flex,Flex4,Flex Spark,我的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="

我的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>

解决方案是使用explicitHeight属性而不是height。这是因为高度是Flex使用的特殊属性符号

从SetProperty的“假名”属性:

/**
 *  @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"
};
所以,如果你已经设置了高度,那么实际上设置的是明确的光。请记住另一个相关属性,称为related_PROPERTIES。它包含关于宽度和高度百分比的附加数据以及明确的宽度和高度信息

有关更多信息,请参阅mx.states.SetProperty

为了解决这种情况下的问题,我们将其更改为:

            <s:SetAction target="{this}" property="height"/>

为此:

            <s:SetAction target="{this}" property="explicitHeight"/>