views:

12

answers:

1

working in flex 4

i have a variable:

[Bindable]
public var visibility:Boolean = true;

these effects:

<fx:Declarations>
    <mx:Fade id="fadeOut" duration="800" alphaFrom="1.0" alphaTo="0.0"/>
    <mx:Fade id="fadeIn" duration="800" alphaFrom="0.0" alphaTo="1.0"/>
</fx:Declarations>

and the following component:

<s:HGroup visible="{visibility}" showEffect="fadeIn" hideEffect="fadeOut">
    ...bunch of stuff...
</s:HGroup>

i have the application set to make visibility=true whenever the mouse is moving, and to set it to false every time the mouse stops moving for 4 seconds. everything works as expected EXCEPT when the mouse moves DURING the animation of the "fadeOut" (in other words, i move the mouse when the alpha of the element is ~0.5). after this happens, i need to wait an additional 4 seconds before moving the mouse, and then the visibility will return.

i have checked, the value of "visibility" does get set back to true when the mouse moves during the animation (and even immediately afterward, even though it doesn't cause visibility to return)... so i am assuming there is something specific and weird about how Flex updates the bound variables and/or visibility states during an animation.

anyone have any ideas?

thanks in advance

A: 

finally found something helpful:

effects have a few functions to help you deal with these kinds of situations. mainly

Effect.pause()
Effect.reverse()
Effect.stop()
Effect.resume()

in Flex 4, these things seem to have weird behaviors. i tried doing fadeOut.reverse(), which actually does what you'd expect, except at the end of the animation, the objects still became invisible... bleh

calling fadeOut.stop(), for some reason, does what i'm looking for, however the proper solution seems to be to use state transitions with the autoReverse attribute set to the currently fading item. then when your state switches back in the middle of the animation, Flex will handle it gracefully.

for an example of the state transitions with autoreverse, check this out: http://graphics-geek.blogspot.com/2010/01/video-auto-reversing-transitions-in.html

handler