I commonly have in and out transitions for almost every view, sub view, and even component in my project. I often write my projects in pure AS3, so each class gets a transitionIn() and transitionOut() method dispatching completion events so I can synchronize transitions across views. All my mojo happens with TweenMax and clients love it.
I’ve been doing a lot more Spark skinning in Flex projects, so I was curious how I could accomplish the same using States, Transitions, and the newer Spark animation stuff.
All the examples I’ve found are flat….the component manages it’s own states and directly transitions the children on its stage. Maybe I’m a dork, but my stuff isn’t so simple. When state changes in a component, it often needs to initiate in/out transitions on many children before just removing them from the stage. Dig?
A component will receive addedToStage or removedFromStage events when its parent changes state and the component is included or excluded from that state.
Main view has 2 states, state1 and state2. When the button is clicked, it will toggle between states and change its label. There’s a logo on the screen that is included only in state2, has its own 2 states (hidden and visible), and includes transitions between each.
If I let the main transition from state2 to state1 run by itself, it will remove the logo from the stage before logo has completed its own transition. I want the main transition to wait until the logo is done transitioning out before removing it from the stage.
It’s actually quite simple to do this. The key is using s:Pause in the main transition to listen for an event before proceeding…» continue reading
Categories: Flex • Permalink