0

有没有一种简单的方法,只使用 MXML,在添加和删除元素的状态之间转换。

例如:

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

例如,MXML 转换能否将 state1 滑出和 state2 滑入?

谢谢你。

4

1 回答 1

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>

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

于 2012-10-25T22:42:46.040 回答