Creating an instance of an effect using pure ActionScript
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="white" initialize="initMe()">
<mx:Script>
import flash.utils.Timer;
import mx.effects.Glow;
[Bindable]
public var secondsTillDue:int = 120;
public var myTimer:Timer;
public var myEffect:Glow;
public function initMe():void
{
myTimer = new Timer(1000);
myTimer.addEventListener('timer',warnIfClose);
myTimer.start();
myEffect = new Glow();
myEffect.alphaFrom = 1.0;
myEffect.alphaTo = 0.3;
myEffect.blurXFrom = 0.0;
myEffect.blurXTo = 50.0;
myEffect.blurYFrom = 0.0;
myEffect.blurYTo = 50.0;
myEffect.color = 0xFF0000;
myEffect.duration = 750;
}
public function warnIfClose(event:TimerEvent):void
{
secondsTillDue=secondsTillDue-1;
if(secondsTillDue < 90)
{
myEffect.target = idDueLabel;
myEffect.play();
}
}
</mx:Script>
<mx:Label text="This is due in {secondsTillDue} seconds"
id="idDueLabel" />
</mx:Application>
Related examples in the same category