as3.0写法,舞台上有一个实例名称为time的动态文本框
------------------------------------------------
function timelist() {
var nowdate:Date = new Date();
//创建新的日期对象,用来获取现在的时间
var year:Number = nowdate.getFullYear();
//获取当前的年份
var month:Number = nowdate.getMonth()+1;
//获取当前的月份,因为数组从0开始用0-11表示1-12月,所以要加1
var date:Number = nowdate.getDate();
//获取当前日期
var day:Number = nowdate.getDay();
//获取当年的星期
var hour:Number = nowdate.getHours();
//获取当前小时
var minute:Number = nowdate.getMinutes();
//获取当前的分钟
var second:Number = nowdate.getSeconds();
//获取当前的秒钟
trace("今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second);
time.text = "今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second;
}
timelist();
setInterval(timelist, 1000);
-------------------------------------------------------------------
as2.0的写法
-----------------------------------------------------------------
function timelist() {
nowdate = new Date();
//创建新的日期对象,用来获取现在的时间
year = nowdate.getFullYear();
//获取当前的年份
month = nowdate.getMonth()+1;
//获取当前的月份,因为数组从0开始用0-11表示1-12月,所以要加1
date = nowdate.getDate();
//获取当前日期
day = nowdate.getDay();
//获取当年的星期
hour = nowdate.getHours();
//获取当前小时
minute = nowdate.getMinutes();
//获取当前的分钟
second = nowdate.getSeconds();
//获取当前的秒钟
trace("今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second);
time.text = "今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second;
}
timelist();
setInterval(timelist, 1000);
------------------------------------------------
function timelist() {
var nowdate:Date = new Date();
//创建新的日期对象,用来获取现在的时间
var year:Number = nowdate.getFullYear();
//获取当前的年份
var month:Number = nowdate.getMonth()+1;
//获取当前的月份,因为数组从0开始用0-11表示1-12月,所以要加1
var date:Number = nowdate.getDate();
//获取当前日期
var day:Number = nowdate.getDay();
//获取当年的星期
var hour:Number = nowdate.getHours();
//获取当前小时
var minute:Number = nowdate.getMinutes();
//获取当前的分钟
var second:Number = nowdate.getSeconds();
//获取当前的秒钟
trace("今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second);
time.text = "今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second;
}
timelist();
setInterval(timelist, 1000);
-------------------------------------------------------------------
as2.0的写法
-----------------------------------------------------------------
function timelist() {
nowdate = new Date();
//创建新的日期对象,用来获取现在的时间
year = nowdate.getFullYear();
//获取当前的年份
month = nowdate.getMonth()+1;
//获取当前的月份,因为数组从0开始用0-11表示1-12月,所以要加1
date = nowdate.getDate();
//获取当前日期
day = nowdate.getDay();
//获取当年的星期
hour = nowdate.getHours();
//获取当前小时
minute = nowdate.getMinutes();
//获取当前的分钟
second = nowdate.getSeconds();
//获取当前的秒钟
trace("今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second);
time.text = "今天是"+year+"年"+month+"月"+date+"日"+"星期"+day+"现在时刻"+hour+":"+minute+":"+second;
}
timelist();
setInterval(timelist, 1000);