1

我在这里有一个测试应用程序,它是使用以下代码制作的:

<fx:Script>
    <![CDATA[

            public function comboBoxHandler():void{
                var selectedItem:String = showComboBox.selectedItem;

                if(selectedItem == "All results"){
                    currentState = "default";
                    return;
                }else if(selectedItem == "Only results within tags"){
                    currentState = "tagInput";
                    return;
                }
            }

    ]]>
</fx:Script>    
<s:states>
    <s:State name="default"/>
    <s:State name="tagInput"/>
</s:states>
<s:transitions>
    <s:Transition id="showTagTextInput" fromState="default" toState="tagInput">
        <s:Sequence id="t1p1" targets="{[tagsLabel,tagsTextInput,GoButton]}">

            <s:Move  duration="700"/>
            <s:Fade  duration="400"/>

        </s:Sequence>
    </s:Transition>
    <s:Transition id="hideTagTextInput" fromState="tagInput" toState="default">
        <s:Sequence id="t2p1" targets="{[tagsLabel,tagsTextInput,GoButton]}" >

            <s:Fade  duration="400"/>
            <s:Move  duration="700"/>

        </s:Sequence>
    </s:Transition>

</s:transitions>

<s:Label x="136" y="13" width="120" height="34" fontFamily="Arial" fontSize="15"
             text="Lessons&#xd;Learnt" textAlign="center"/>

    <s:Group id="group" width="100%" height="100%"
             x.default="0" y.default="55" width.default="400" height.default="231"
             y.tagInput="55" height.tagInput="256">
        <s:Label x="45" y="38" width="50" height="22" text="Search" textAlign="center"
                 verticalAlign="middle"/>
        <s:TextInput x="103" y="38" width="193"
                     useHandCursor.tagInput="false"/>
        <s:Label x="45" y="89" width="51" height="22" text="Show" textAlign="center"
                 verticalAlign="middle"/>
        <s:Button id="GoButton" x="253" y="137" width="43" label="Go" useHandCursor="true"
                  buttonMode="true" mouseChildren="false"
                  x.tagInput="254" y.tagInput="188"/>
        <s:DropDownList id="showComboBox" x="104" y="89" width="192" change="comboBoxHandler();"
                    selectedIndex="0">
            <s:ArrayCollection>
                <fx:String>All results</fx:String>
                <fx:String>Only results within tags</fx:String>
            </s:ArrayCollection>
        </s:DropDownList>
        <s:Label id="tagsLabel" includeIn="tagInput" x="104" y="146" width="61" height="20" text="Tags"
                 textAlign="center" verticalAlign="middle"/>
        <s:TextInput id="tagsTextInput" includeIn="tagInput" x="173" y="146" width="123"/>

    </s:Group>

您可以通过单击我提供的链接来检查,当您从 DropDownBox 选择不同的选项时,此应用程序会执行一些基本的过渡效果。

第一个(显示)过渡效果不太好,但第二个(隐藏)过渡效果很好。

有谁知道如何解决这个问题?在第一次转换中,我希望按钮先向下滑动然后文本输入才会淡入。为什么这不起作用?

提前致谢。

4

2 回答 2

2

最好指向特定的效果目标,而不是指向所有目标<s:Sequence />。所以将目标放置到<s:Move /><s:Fade />。您还可以通过放置<s:AddAction /><s:RemoveAction />使用相应的目标来执行其他转换调整,以指向序列中应调用转换includeInexcludeFrom状态声明的位置。

因此,这些转换适用于您的代码:

<s:transitions>
    <s:Transition fromState="default" id="showTagTextInput" toState="tagInput">
        <s:Sequence id="t1p1">
            <s:Move duration="700" targets="{[GoButton]}" />
            <s:AddAction targets="{[tagsLabel,tagsTextInput]}" />
            <s:Fade duration="400" targets="{[tagsLabel,tagsTextInput]}" />
        </s:Sequence>
    </s:Transition>
    <s:Transition fromState="tagInput" id="hideTagTextInput" toState="default">
        <s:Sequence id="t2p1">
            <s:Fade duration="400" targets="{[tagsLabel,tagsTextInput]}" />
            <s:RemoveAction targets="{[tagsLabel,tagsTextInput]}" />
            <s:Move duration="700" targets="{[GoButton]}" />
        </s:Sequence>
    </s:Transition>
</s:transitions>
于 2011-05-17T15:14:20.693 回答
1

我想这是因为您的标签输入仅包含在 tagInput 状态中,但 alpha 为 100%,并且状态之间没有转换。试试这个:

<s:Label id="tagsLabel" alpha.default="0" alpha.tagInput="100" x="104" y="146" width="61" height="20" text="Tags" textAlign="center" verticalAlign="middle"/>
<s:TextInput id="tagsTextInput" alpha.default="0" alpha.tagInput="100" x="173" y="146" width="123"/>

您可能还希望在“默认”状态下将可见设置为 false。此外,康斯坦丁说的是真的。

于 2011-05-17T15:19:53.080 回答