2016-10-13 00:16:48 点击量:14 标签: 收藏本文
在AS3中保留了原始的用法,setInterval()与setTimeout()依然是可以使用的,跟AS2.0有所不同的是增加了,Timer()方法。
1、原始方法:
setInterval(closure:Function, delay:Number, ... arguments):uint
setTimeout(closure:Function, delay:Number, ... arguments):uint
注意返回类型是uint,所在CLASS:flash.utils.*
2、新方法:
- package
- {
- import flash.display.Sprite;
- import flash.events.TimerEvent;
- import flash.utils.Timer;
- public class ShortTimer extends Sprite
- {
- public function ShortTimer()
- {
- // cuplayer.com提示creates a new five-second Timer
- var minuteTimer:Timer = new Timer(1000, 5);
- // designates listeners for the interval and completion events
- minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
- minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
- // cuplayer.com提示starts the timer ticking
- minuteTimer.start();
- }
- public function onTick(evt:TimerEvent):void
- {
- // cuplayer.com提示displays the tick count so far
- // The target of this event is the Timer instance itself.
- trace("tick " + evt.target.currentCount);
- }
- public function onTimerComplete(evt:TimerEvent):void
- {
- trace("Time's Up!");
- }
- }
- }
- cuplayer.com提示输出结果如下:
- tick 1
- tick 2
- tick 3
- tick 4
- tick 5
- Time's Up!
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室