flex定时器的基本实现
来源:互联网 发布:仿2017小米商城源码 编辑:程序博客网 时间:2024/04/30 11:06
- <?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"
- creationComplete="init()"
- minWidth="955" minHeight="600">
- <fx:Declarations>
- </fx:Declarations>
- <fx:Script>
- <![CDATA[
- import com.common.util.AlertUtil;
- import mx.controls.Alert;
- private var time:Timer;
- private var count:int=0;
- protected function init():void
- {
- time = new Timer(1000);
- time.addEventListener(TimerEvent.TIMER,timeHandler);
- time.start();
- }
- public function timeHandler(evt:TimerEvent):void
- {
- count++;
- this.timer.text="第"+count+"次响应";
- }
- ]]>
- </fx:Script>
- <s:Label x="100" y="100" id="timer" text="第0次响应"/>
- </s:Application>