In Flex 4, state transition doesn't resize in

2019-08-13 22:27发布

问题:

I already had another question on this issue which was successfully resolved. But now, with a slightly different example, I'm stuck again.

I have two states. When I switch from A to B, it resizes correctly, but when I switch from B back to A it happens without the smooth resize transition. What am I doing wrong?

Here's my code:

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

Thanks in advance, Nuno

回答1:

You need to use a Sequence instead of a Parallel.