Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Flex Developer Center / Flex Quick Starts /

Defining state transitions

by Adobe

Adobe logo

Created

22 March 2010

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flex

Requirements

User level

All

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

This content requires Flash To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

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.

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

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

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

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.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement