Blinking Label in Flex

I was working on a project and I had to come up with a BlinkingLabel; label/text that blinks giving the user some alert/messaging signal. After trying the internet to no avail, I had to deep my head in the toolbox and cook something up. I hope this helps someone. I would also love any bug, improvement and the likes posted to this blog.

Code after jump::

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Label xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; creationComplete=”init()”>

<mx:Script>
<![CDATA[
import mx.effects.Parallel;
import mx.effects.Fade;

private var fadeTimer:Timer = new Timer(700);

private function init():void
{    
fadeTimer.addEventListener(TimerEvent.TIMER, timerFunction);
fadeTimer.start();
}

public function startBlink():void
{
activeplay.end();
activeplay.play();
}

private function timerFunction(event:TimerEvent):void
{
startBlink();
}

]]>
</mx:Script>

<mx:filters>
<mx:BlurFilter blurX=”0″ blurY=”0″/>
</mx:filters>

<mx:Parallel id=”activeplay”>
<mx:Fade id=”fadeIn” alphaFrom=”0.0″ alphaTo=”1.0″ target=”{this}” duration=”250″/>
<mx:Fade id=”fadeOut” alphaFrom=”1.0″ alphaTo=”0.0″ target=”{this}” duration=”250″/>
</mx:Parallel>

</mx:Label>

So to use this just add it into your application, say, <widgets:BlinkingLabel text=”I am blinking”/> and that should do it.

Note that the name of the component as I named it is BlinkingLabel as you must have guessed.

 

Enjoy

 

 

Advertisements

One thought on “Blinking Label in Flex

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s