2016-10-13 00:16:48 点击量:12 标签: 收藏本文
[AS3]as3使用日期和时间的例子源代码,日历日期时间及时间间隔,计时分别由Date类,flash.utile.Timer类来提供。
* 日期时间
- //定义日期时间
- var now:Date = new Date(); //无参数定义日期时间,为当前时间
- var startTime:Date = new Date(1000*60*60*24); //1个参数毫秒数,自1970-1-1以来经过的毫秒数
- var endTime:Date = new Date(2013,5,19,16,20,59,234); //参数为年、月、日、小时、分钟、秒和毫秒
- //获取日期时间相应属性
- /*
- • fullYear 属性
- • month 属性,以数字格式表示,分别以 0 到 11 表示一月到十二月
- • date 属性,表示月中某一天的日历数字,范围为 1 到 31
- • day 属性,以数字格式表示一周中的某一天,其中 0 表示星期日
- • hours 属性,范围为 0 到 23
- • minutes 属性
- • seconds 属性
- • milliseconds 属性
- */
日期值在内部以毫秒形式保存,日期时间的加减运算可以换算成毫秒再加减。
* 时间间隔
- package
- {
- import flash.display.Sprite;
- import flash.events.TimerEvent;
- import flash.utils.Timer;
- public class ShortTimer extends Sprite
- {
- public function ShortTimer()
- {
- // 酷播提示: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);
- // starts the timer ticking
- minuteTimer.start();
- }
- public function onTick(event:TimerEvent):void
- {
- // displays the tick count so far
- // The target of this event is the Timer instance itself.
- trace("tick " + event.target.currentCount);
- }
- public function onTimerComplete(event:TimerEvent):void
- {
- trace("酷播提示:Time's Up!");
- }
- }
- }
[AS3]as3使用日期和时间的例子源代码
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室