- 在场景中第一层第一帧放一个动态文本框,取实例名称为mytime,在第二帧插入帧。
- 新建图层2,输入代码:
var rightnow = new Date();
var weekday = rightnow.getDay();
var themonth = rightnow.getMonth();
var thedate = rightnow.getDate();
var theyear = rightnow.getYear();
var someday = new Array(7);
someday[0] = "星期日";
someday[1] = "星期一";
someday[2] = "星期二";
someday[3] = "星期三";
someday[4] = "星期四";
someday[5] = "星期五";
someday[6] = "星期六";
themonth = themonth + 1;
if (theyear < 2000)
{
theyear = theyear + 1900;
}
var thehours = rightnow.getHours();
var themins = rightnow.getMinutes();
var theseconds = rightnow.getSeconds();
if (thehours < 10)
{
thehours = "0" + thehours;
}
if (themins < 10)
{
themins = "0" + themins;
}
if (theseconds < 10)
{
theseconds = "0" + theseconds;
}
mytime.text = theyear + "年" + themonth + "月" + thedate + "日" + someday[weekday] + "\n" + thehours + "时" + themins + "分" + theseconds + "秒";