你可以使用Fade指定所有元素进行转换,而不单独列出吗?

时间:2011-05-27 22:06:41

标签: flex4 transitions

我已经开始了一个空中应用程序了,我正试图在状态之间使用Fade进行转换(一个序列应该在理论上淡出,然后淡出下一个状态。)有没有办法目标它淡出所有元素,或者我需要使用targets =“...”并列出每个元素?

我已经尝试将所有元素嵌套在一个组中,但这似乎不起作用。

我当前代码的缩短版本:

<s:states>
    <s:State name="HomeScreen"/>
    <s:State name="EnemyBuilder"/>
    <s:State name="EncyclopediaBuilder"/>
</s:states>
<fx:Declarations>
    <s:Transition toState="*" fromState="*" >
        <s:Sequence >
            <s:Fade alphaFrom="1" alphaTo="0" duration="250" target="{wrapper}" />
            <s:Fade alphaFrom="0" alphaTo="1" duration="250" target="{wrapper}" />
        </s:Sequence>
    </s:Transition> 
</fx:Declarations>

<s:Group id="wrapper" includeIn="HomeScreen, EnemyBuilder, EncyclopediaBuilder" >

<s:BorderContainer id="encounter" includeIn="HomeScreen" 
                   x="49" y="99" width="200" height="44" 
                   styleName="falseButton"
                   rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
    <s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
    <s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
    <s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder" 
                   right="20" bottom="20" width="200" height="44"
                   styleName="falseButton"
                   rollOut="alphaOver(event)" rollOver="alphaOver(event)"
                   click="currentState='HomeScreen'" >
    <s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
    <s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>        
</s:BorderContainer></s:Group>  

1 个答案:

答案 0 :(得分:1)

尝试使用以下内容:

<s:states>
    <s:State name="HomeScreen"/>
    <s:State name="EnemyBuilder"/>
    <s:State name="EncyclopediaBuilder"/>
</s:states>
<s:transitions>
    <s:Transition toState="*" fromState="*" >
        <s:Sequence target="{wrapper}">
            <s:Fade alphaFrom="1" alphaTo="0" duration="250" />
            <s:Fade alphaFrom="0" alphaTo="1" duration="250" />
        </s:Sequence>
    </s:Transition> 
</s:transitions>

<s:Group id="wrapper">

<s:BorderContainer id="encounter" includeIn="HomeScreen" 
                   x="49" y="99" width="200" height="44" 
                   styleName="falseButton"
                   rollOut="alphaOver(event)" rollOver="alphaOver(event)" click="currentState='EncyclopediaBuilder'" >
    <s:Label x="48" y="8" color="#000000" fontFamily="Arial" text="Create a new encounter" />
    <s:Label x="48" y="24" color="#000000" fontStyle="italic" text="Single encounter" />
    <s:Image x="10" y="10" source="assets/001_01.png" />
<s:BorderContainer id="back" includeIn="EncyclopediaBuilder" 
                   right="20" bottom="20" width="200" height="44"
                   styleName="falseButton"
                   rollOut="alphaOver(event)" rollOver="alphaOver(event)"
                   click="currentState='HomeScreen'" >
    <s:Label x="48" y="16" color="#000000" fontFamily="Arial" text="Save and Return"/>
    <s:Image x="10" y="10" source="assets/001_01.png"/>
</s:BorderContainer>        
</s:BorderContainer></s:Group>