5D的《深入FLASH5编程》这本书15页有一个电子钟的实例。照着做了以后其他都显示正常
就是dayname和monthname不能正常显示。而且,做出来以后比计算机时间快一个小时。
月份晚一个月。不知道是什么原因。代码如下:
onClipEvent (load) {
days = newArray('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
months = newArray('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
timedate = new date();
}
onClipEvent (enterFrame) {
hour = timedate.gethours();
minutes = timedate.getminutes();
seconds = timedate.getseconds();
todaydate = timedate.getdate();
day = timedate.getday();
dayname = days[day];
month = timedate.getmonth();
monthname = months[month];
year = timedate.getfullyear();
if (length(minutes) == 1) {
minutes = "0"+minutes;
}
if (length(seconds) == 1) {
seconds = "0"+seconds;
}
if (length(month) == 1) {
month = "0"+month;
}
currenttime = hour+":"+minutes+":"+seconds;
currentdate = todaydate+"/"+month+"/"+year;
fulldate = dayname+" "+todaydate+" "+monthname+" "+year;
delete timedate;
timedate = new date();
}