Flex3学习轨迹:创建简单的过渡

mx:Transition

利用视图状态可以改变应用程序的内容和外观。当改变视图外观时,FLex会在同一时间内对应用程序执行所有的可视化修改。然而在默认情况下这个跳转过程比较突然,效果生硬。为让这一过程变得平滑和多样,Flex提供了一种称之为“过渡”的技术特性。

mx:Transition标签提供三个属性fromState toState effect 属性用于设置过渡过程中要播放的Effect对象。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12">
    <!-- 定义过渡 -->
    <mx:transitions>
        <mx:Transition fromState="" toState="details">
            <mx:Parallel>
                <mx:Move target="{image1}" duration="500" 
                    xFrom="53" xTo="110" />
                <mx:WipeRight target="{v2}" duration="500"/>
            </mx:Parallel> 
        </mx:Transition>
        <mx:Transition fromState="details" toState="">
        	<mx:Fade target="{image1}" duration="1000" 
                	alphaFrom="0.0" alphaTo="1.0" />            
        </mx:Transition>
    </mx:transitions>
    <!-- 定义富态 -->
    <mx:states>
        <mx:State name="details">
            <mx:AddChild relativeTo="{h1}" position="firstChild">
                <mx:VBox id="v2">
                    <mx:Label text="品牌:戴尔" />
                    <mx:Label text="尺寸:22寸" />
                    <mx:Label text="价格:2500RMB" />
                </mx:VBox>
            </mx:AddChild>
            <mx:SetProperty target="{label1}" name="label" value="基本参数" />
            <mx:SetStyle target="{label1}" name="color" value="blue" />
        </mx:State>
    </mx:states>
    <!-- 定义基态 -->
    <mx:Panel title="创建过渡" width="250" height="190" 
        verticalAlign="middle" horizontalAlign="center">
        <mx:VBox id="v1" verticalCenter="true" horizontalAlign="center">
            <mx:HBox id="h1" width="100%">
                <mx:Image id="image1" source="assets/dellDisplay.jpg" />
            </mx:HBox>
            <mx:LinkButton id="label1" label="我的显示器" fontWeight="bold" 
                click="currentState = currentState=='details' ? '':'details';" />
        </mx:VBox>
    </mx:Panel>
</mx:Application>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值