Flex 4简化国家间过渡的方式

时间:2012-10-21 23:03:54

标签: flex flex4 transitions

是否有一种简单的方法,仅使用MXML,在添加和删除元素的状态之间进行转换。

例如:

<s:Group includeIn="state1"/>
<s:Group includeIn="state2"/>

MXML过渡可以将state1和state2滑入,例如?

谢谢。

2 个答案:

答案 0 :(得分:0)

除了上面发布的链接之外,还有一种方法可以将单个转换应​​用于多个目标:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:views="views.*"  >

    <s:states>
        <s:State name="home"/>
        <s:State name="help"/>
        <s:State name="instructions"/>
        <s:State name="settings"/>
        <s:State name="feedback"/>
    </s:states>

    <s:transitions>
        <s:Transition fromState="*" toState="*" >
            <s:Sequence >
                <s:Wipe direction="right" duration="350" target="{this}"/>
            </s:Sequence>
        </s:Transition>
    </s:transitions>

    <views:Home         id="home"       includeIn="home"            width="100%" height="100%" ownerComponent="{this}"/>
    <views:Help         id="help"       includeIn="help"            width="100%" height="100%" ownerComponent="{this}" />
    <views:Instructions id="instructions"   includeIn="instructions"    width="100%" height="100%" ownerComponent="{this}" />
    <views:Settings     id="settings"   includeIn="settings"        width="100%" height="100%" ownerComponent="{this}" />
    <views:Feedback     id="feedback"   includeIn="feedback"        width="100%" height="100%" ownerComponent="{this}" />

</s:Group>

上一次转换会从一个方向创建另一个方向。

下一个过渡从一个视图消失到另一个视图:

<s:transitions>
    <s:Transition fromState="*" toState="home" >
        <s:Sequence >
            <s:Fade target="{this}" alphaFrom="1" alphaTo="0"/>
            <s:RemoveAction targets="{[home,help,instructions,settings,feedback]}"/>
            <s:AddAction target="{home}"/>
            <s:Fade target="{this}" alphaFrom="0" alphaTo="1"/>
        </s:Sequence>
    </s:Transition>
</s:transitions>

下一个视图在滑动其余视图时滑动:

<s:transitions>
    <s:Transition fromState="*" toState="home" >
        <s:Sequence duration="1000" >
            <s:Parallel>
                <s:Move applyChangesPostLayout="true" targets="{notHomeTargets}" xFrom="0" xTo="{-width}"/>
                <s:AddAction target="{home}" />
                <s:Move applyChangesPostLayout="true" target="{home}" xFrom="{width}" xTo="0"/>
            </s:Parallel>
            <s:RemoveAction targets="{targets}" />
        </s:Sequence>
    </s:Transition>
</s:transitions>

您必须使用最后一个示例为每个州创建一个。

答案 1 :(得分:0)