在Flex 4中,状态转换不会在两个方向上调整大小(v2)

时间:2011-04-05 17:01:59

标签: flex flex4 state transition transitions

我已经成功解决了这个问题another question。但现在,只是略有不同的例子,我再次陷入困境。

我有两个州。当我从A切换到B时,它会正确调整大小,但是当我从B切换回A时,它会在没有平滑调整大小的情况下发生。我做错了什么?

这是我的代码:                  

      <fx:Script>
        <![CDATA[
          protected function rollOverHandler(event:MouseEvent):void
          {
            this.currentState = "AB";
          }

          protected function rollOutHandler(event:MouseEvent):void
          {
            this.currentState = "A";
          }

        ]]>
      </fx:Script>

      <fx:Declarations>
      </fx:Declarations>

      <s:states>
        <s:State name="A" />
        <s:State name="AB" />
      </s:states>

      <s:transitions>

        <s:Transition fromState="A" toState="AB" autoReverse="true">
          <s:Parallel>
            <s:AddAction target="{controls}"/>      
            <s:Resize duration="500" target="{controls}" heightFrom="0"  />
          </s:Parallel>
        </s:Transition>

        <s:Transition fromState="AB" toState="A" autoReverse="true">
          <s:Parallel>
            <s:Resize duration="500" target="{controls}" heightTo="0" />
            <s:RemoveAction target="{controls}"/>
          </s:Parallel>
        </s:Transition>

      </s:transitions>

      <s:BorderContainer width="300" 
                         backgroundColor="#eeeeee" 
                         borderVisible="false"
                         minHeight="0">
        <s:layout>
          <s:VerticalLayout gap="0"/>
        </s:layout>
        <s:VGroup id="data">
          <s:Label text="A" fontSize="40" />  
        </s:VGroup>
        <s:VGroup id="controls" 
                  clipAndEnableScrolling="true" 
                  itemCreationPolicy="immediate"
                  includeIn="AB">
          <s:Label text="B" fontSize="40" />  
        </s:VGroup>
      </s:BorderContainer>

    </s:HGroup>

提前致谢, 努诺

1 个答案:

答案 0 :(得分:1)

您需要使用序列而不是并行。