Tuesday, November 21, 2006

Getting Effects to play when transitioning back

Simple little task. Click a button [State:Login], have it fade out, change viewstate, have new panel fade in [State:Register]. Works like a charm. Now, click button on panel, have panel fade out, change viewstate, have button fade back in. Also do the same thing with the WipeUp and WipeDown effect.

Problem. Transitions to the Register state work fine, but transitions back to the original Login State don't. The panel just disappears, no fade, and then the button [State:Login] fades back in nicely. It appears that the controls in the Register State are removed by default before any effects can play visually on them. Using a Sequence and setting the duration of the Panel fade to 10 seconds proves that the effect does play, since it delays the fade in of the button [State:Login], however the control is no longer visible because we're no longer in the Register State.

I realize this is probably confusing... but those of you that have come across this same problem will recognize it. I poured over the LiveDocs but it took just alot of troubleshooting different ideas before I got it working. I've posted a working demo in my Flex Projects column to the right. As usual, right click on the demo to get at the source.

2 comments:

Chris Simeone said...

Victor,

I have a similar problem. I switch to a "splash" view state and my fade in effect works - the splash screen fades in.

When I switch back to the base state my the "splash" view state, the fade out effect fails; the screen just goes away.

What was your solution?

Thanks!
Chris

chris.simeone@daveramsey.com

Vic Rubba said...

You have to put the transition in a sequence, where you play the fade first, and then call <mx:RemoveChildAction/>. I've emailed you a sample flex app that should help.