O'Reilly logo

Learning Flex 4 by Elijah Robison, Alaric Cole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transitions

By now you should be fairly comfortable applying effects to your display objects and using events to trigger their play() method. However, you have another option: you can use state changes as an opportunity to trigger effects. In Flex terminology, it’s called a transition.

Transition Syntax

For the most part, if you know how to program effects, then you know how to program state change transitions. The only real differences are where you declare the effects in your application code. Here’s a breakdown of the differences:

  • Transition effects are nested inside an <s:Transition/> block, which is nested inside an <s:transitions/> block; they are not placed in the Declarations section. They are typically placed just below any State definitions you’ve created.

    <s:transitions>
    
        <s:Transition>
    
            <!-- effect goes here -->
    
        </s:Transition>
    
    </s:transitions>
  • The states affected by a transition are explicitly declared as property attributes of the <s:Transition/> instance—specifically, fromState and toState.

    <s:transitions>
    
        <s:Transition fromState="firstState" toState="secondState">
    
            <!-- effect goes here -->
    
        </s:Transition>
    
    </s:transitions>
  • You’ll handle target assignments for transition effects within the effects’ MXML declarations. If the transitions are animating changing property values, those values are supplied behind the scenes by state-property assignments.

    Note

    There is an alternative to this last approach called target filtering, which we discuss toward the end of this section.

    <s:transitions> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required