Search code examples
apache-flexeffectvisibleinvisible

Flex hide Text 2 seconds after it's shown


I have this scenario I'm trying to accomplish: I have Text that is always on the screen, but most of the time visible is set to false. I have a handler that when an event occurs it makes this Text visible. Easy enough so far. The next requirement though, is to add an effect to this Text to make it go away 2 seconds after it appears. So essentially I need an effect to wait 2 seconds and then set visible back to false.

I've never worked with effects before in Flex though so I don't really even know where to start. Thanks for the guidance!


Solution

  • All you need is to start a Timer(2000) of 2 seconds and one the TimerEvent.Timer event to set the text field visible = false;

    Update: (after 1st comment)

    You can also do the following but not so nice from programming side, at the end still using a timer or something similar in the background.

    <mx:Text
         showEffect="myHideFadeEffect"/>
    
    <mx:FadeEffect
        id        = "myHideFadeEffect"
        alphaFrom = "1"
        alphaTo   = "0"
        startDelay= "2000"/>
    

    But once again I do not recommend this approach.