onEnterFrame = function () {
time_date = new Date();
se = new String();
var ts = time_date.getSeconds();
se = ts;
if (ts<10) { // 设定显示时间的格式如果是小于0,比如3,那么就显示03
se = "0"+ts;
}
mi = new String();
var tm = time_date.getMinutes();
mi = tm;
if (tm<10) {
mi = "0"+tm;
}
ho = new String();
var th = time_date.getHours();
ho = th;
if (th<10) {
ho = "0"+th;
}
time_txt.text = ho+":"+mi+":"+se; // 显示格式为 xx : xx : xx
date_txt.text = (time_date.getYear()-100)+"' "+time_date.getDate()+" "+(time_date.getMonth()+1);
var week = new String();
switch (time_date.getDay()) { // 设定星期的格式
case 1 :
week = "Mon";
break;
case 2 :
week = "Tus";
break;
case 3 :
week = "Wed";
break;
case 4 :
week = "Thu";
break;
case 5 :
week = "Fri";
break;
case 6 :
week = "Sta";
break;
case 0 :
week = "Sun";
break;
}
if (!time_date.getDay()) { // 特殊设定,当天如果是星期天,那么把字体显示为红色
week_txt.textColor = 0xdd0000; // textColor后是跟一个16进制的颜色,这里为红色
}
week_txt.text = week;
};
// AS中的以_txt结尾的就是动态文本的"标签"(实例名称),可以调用text以及textColor属性