![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()" > <s:layout> <s:VerticalLayout paddingLeft="20" paddingTop="20"/> </s:layout> <fx:Script> <![CDATA[ import flash.utils.Timer; import mx.controls.Alert; import spark.effects.animation.RepeatBehavior; [Bindable] protected var secondsTillDue:int = 10; protected var _timer:Timer; protected function init():void{ _timer = new Timer(1000); _timer.addEventListener(TimerEvent.TIMER,onTimerTick); _timer.start(); } protected function onTimerTick(event:TimerEvent):void{ secondsTillDue = Math.max(secondsTillDue-1,0); if(secondsTillDue == 0) { effect.play(); _timer.stop(); see.visible =true; } } ]]> </fx:Script> <fx:Declarations> <s:GlowFilter id="filter" color="#4e7800" blurX="20" blurY="20"/> <s:AnimateFilter id="effect" target="{box}" bitmapFilter="{filter}" duration="1000" repeatCount="0" repeatBehavior="{RepeatBehavior.REVERSE}"> <s:SimpleMotionPath property="alpha" valueFrom="0" valueTo="1"/> </s:AnimateFilter> </fx:Declarations> <s:Label id="labelField" fontWeight="bold" fontSize="14" text="倒计时{secondsTillDue}秒"/> <s:Rect id="box" width="200" height="200"> <s:fill> <s:SolidColor color="black"/> </s:fill> </s:Rect> <s:Label id="see" text="触发了" visible="false"/> </s:Application>