tags:

views:

679

answers:

1

I would like to show some hidden text in a Flex application and have it fade out in a couple of seconds...

I have looked into Delay and Pause effects in Flex, but have yet to see an example of how to do this realistically easy effect...

anyone now how to do it or have a good resource?

Thanks.

+2  A: 

If I understand you correctly, you want to have the text automatically fade out a few seconds after it is shown?

I would probably do something like this: (Haven't tested the code, so there are probably typos.)

<mx:Script>
    import flash.utils.*;

    var fadeTimer:Timer = new Timer(2000); // 2 seconds
    fadeTimer.addEventListener("timer", fadeTimerTickHandler);

    // Call this to show the hidden text.
    function showTheText():void{
        theTextField.visible = true;
        fadeTimer.start();
        }

    // This gets called every time the timer "ticks" (2 seconds)
    function fadeTimerTickHandler(eventArgs:TimerEvent){
       fadeTimer.stop();
       fadeTimer.reset();
       theTextField.visible = false;
       }
</mx:Script>

<mx:Fade id="hideEffectFade" alphaFrom="1.0" alphaTo="0.0" duration="900"/>

<mx:Text id="theTextField" text="The Text" hideEffect="{hideEffectFade}"/>

Also, you need to be sure to embed your fonts or the effect won't work on your text. See Simeon's post for more info.

81bronco