Adobe
产品
Acrobat
Creative Cloud
创意套装
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
更多产品
解决方案
数字营销
数字媒体
教育
金融服务业
政府部门
网页体验管理
更多解决方案
学习帮助下载公司
商店
在线商店
批量许可
查找经销商
搜索
 
信息 登录
欢迎,我的支持
我的帐户
注销
为何登录?登录后可以管理您的帐户,访问试用版下载、产品扩展和社区区域等。
Adobe
产品 分类 购买   搜索  
解決方案 公司
学习
登录 注销 我的货物 我的支持
Date Date
Qty:
Subtotal
Checkout
Adobe 开发者中心 / Flex 开发人员中心 / Flex 快速入门 /

Defining state transitions

by Adobe

Adobe logo

Created

22 March 2010

页面工具

在 Facebook 上共享
在 Twitter 上共享
在 LinkedIn 上共享
书签
打印

Tags

要求

用户级别

全部

View states let you vary the content and appearance of an application, typically in response to a user action. When you change view states, Adobe Flex performs all the visual changes to the application at the same time. Since all the changes to a view state occur at the same time, the application can appear to the user to jump from state to state.

Instead, you might want to define a smooth visual change from one state to the next, in which the change occurs over a period of time. Transitions define how a change of view state looks as it occurs on the screen. A transition is one or more effects grouped together to play when a view state change occurs.

Transitions do not replace effects; that is, you can still apply a single effect to a component, and invoke that effect by using an effect trigger, or the playEffect()method.

You use the <mx:Transition> tag to create a transition and customize it by using its fromState, toState and effect properties. The fromState property specifies the view state that you are changing from when you apply the transition, the toState property specifies the view state that you are changing to and the effect property is a reference to the Effect object to play.

In transitions, you can cause effects to play in parallel or in sequence by using the <s:Parallel> and <s:Sequence> tags.

In the following example, you define a transition that is used whenever a state change occurs. This transition is comprised of a parallel effect. A parallel effect is known as a composite effect as it contains other effects. In this example, the parallel effect contains a resize effect and an animate filter effect. A parallel effect's child effects all run at the same time.

The resize effect takes 500 miliseconds to execute and uses an easing function to make the panel bounce when it resizes. The animate filter effect blurs the targert component for 200 milliseconds. The effect is repeated and reversed to remove the blur.

Example

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="340" height="250"> <!-- DefiningStateTransitions --> <s:layout> <s:VerticalLayout paddingTop="20" horizontalAlign="center"/> </s:layout> <fx:Declarations> <!-- Place non-visual elememnts in a Declarations tag The Bounce class implements easing functionality, simulating gravity pulling on and bouncing the target object. The BlurFilter class lets you soften the details of an image. These effects are applied below in the Transition class for a view state. --> <s:Bounce id="bounce"/> <s:BlurFilter id="blur"/> </fx:Declarations> <s:states> <s:State name="LoginState"/> <s:State name="RegisterState"/> </s:states> <!-- Use the transitions property (array) of the Application class to store your transitions. --> <s:transitions> <!-- The Transition class defines a set of effects that play in response to a change of view state. --> <mx:Transition> <!-- Parallel effects execute in unison --> <s:Parallel> <!-- Resize effect uses Bounce, defined in Declarations --> <s:Resize duration="500" easer="{bounce}" target="{loginPanel}"/> <!-- AnimateFilter effect uses BlurFilter, defined in Declarations --> <s:AnimateFilter target="{confirm}" bitmapFilter="{blur}" duration="200" repeatCount="2" repeatBehavior="reverse"> <s:SimpleMotionPath property="blurY" valueFrom="1" valueTo="20"/> </s:AnimateFilter> </s:Parallel> </mx:Transition> </s:transitions> <fx:Script> <![CDATA[ // Import effects and filters // even if you are only going to use them in MXML import mx.effects.easing.Bounce; import spark.filters.BlurFilter; ]]> </fx:Script> <s:Panel title.LoginState="Login" title.RegisterState="Register" id="loginPanel"> <s:VGroup id="loginForm" left="10" top="10" bottom="10" width="250"> <s:Group> <s:Label text="Username:" baseline="15"/> <s:TextInput x="80" baseline="15"/> </s:Group> <s:Group> <s:Label text="Password" baseline="15"/> <s:TextInput x="80" baseline="15"/> </s:Group> <s:Group includeIn="RegisterState" id="confirm"> <s:Label text="Confirm:" baseline="15"/> <s:TextInput x="80" baseline="15"/> </s:Group> </s:VGroup> <!-- Using VGroup instead of Form because of SDK-25628 bug <mx:Form id="loginForm"> <mx:FormItem label="Username:"> <s:TextInput/> </mx:FormItem> <mx:FormItem label="Password:"> <s:TextInput/> </mx:FormItem> <mx:FormItem includeIn="RegisterState" label="Confirm:" id="confirm"> <s:TextInput/> </mx:FormItem> </mx:Form>--> <s:controlBarContent> <mx:LinkButton label="Need to Register?" includeIn="LoginState" click="currentState='RegisterState'" id="registerLink" /> <mx:LinkButton label="Return to Login" includeIn="RegisterState" click="currentState='LoginState'"/> <mx:Spacer width="100%"/> <s:Button label="Login" id="registerBtn" includeIn="RegisterState"/> <s:Button label="Register" id="loginButton" includeIn="LoginState"/> </s:controlBarContent> </s:Panel> </s:Application>

Result

缺少 Flash player 您必须装有 Flash 10? 您必须装有 Flash 10?

Back to top

For more information

  • Using Transitions
  • Using View States

Back to top


This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.

产品

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • 移动应用程序
  • Photoshop
  • Touch Apps

解决方案

  • 数字营销
  • 数字媒体
  • 网页体验管理

行业

  • 教育
  • 金融服务业
  • 政府部门

帮助

  • 产品帮助中心
  • 订货和退货
  • 下载和安装
  • 我的 Adobe

学习

  • Adobe 开发人员连接
  • Adobe TV
  • 培训和认证
  • 论坛
  • 设计中心

购买方式

  • 在线商店
  • 批量许可
  • 查找经销商

下载

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

公司

  • 新闻编辑室
  • 合作伙伴计划
  • 公司社会责任
  • 工作机会
  • 投资者关系
  • 事件
  • 法律
  • 安全
  • 联系 Adobe
选择您的地区 中国(更改)
选择您的地区 关闭

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

使用条款 | 隐私政策和 Cookies (更新)

京 ICP 备 10217899 号 京公网安备 110105010404