主题:  画魔大闪!!帮我一下好吗???!!!

九头鸟

职务:普通成员
等级:1
金币:0.0
发贴:9
#12001/5/28 21:02:06
这是我照书做的,叫电子钟,也就是《深入FLASH5编程》中的,可是我做完后运行时发现有错误,
所显示的时间与系统时间有不同,所显示的小时要快一个小时,月份要慢一个月,英文的正常。
我照写的代码如下:
onClipEvent (load) {
days = new Array('Sunday','Monday','Tuesday','Wednesday','thursday','Friday','Saturday');
months = new Array('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;
}
currenttime = hour+":"+minutes+":"+seconds;
currentdate = todaydate+"/"+month+"/"+year;
fulldate = dayname+" "+todaydate+" "+monthname+" "+year;
delete timedate;
timedate = new Date();
}

我校对过好几次,但还是没有发现错误的地方特请画魔兄.Dawn兄指点,谢谢!!!



臭豆腐

职务:普通成员
等级:1
金币:0.0
发贴:75
#22001/5/28 23:19:20
请参阅以前的文章
flash时间函数如此计算
0 1 2 3 4 5 6 7 8...........23
1 2 3 4 5 6 7 8 9............0



magicwind

职务:普通成员
等级:1
金币:1.0
发贴:160
#32001/5/29 9:33:47
onClipEvent (load) {
days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
months = new Array("December","January","February","March","April","May","June","July","August","September","October","November","December");
timedate = new Date();
}
onClipEvent (enterFrame) {
hour = timedate.getHours()-1;
minutes = timedate.getMinutes();
seconds = timedate.getSeconds();
todaydate = timedate.getDate();
day = timedate.getDay();
dayname = days[day];
month = timedate.getMonth()+1;
monthname = months[month];
year = timedate.getFullyear();
if (length(minutes)==1) {
minutes = "0"+minutes;
}
if (length(seconds)==1) {
seconds = "0"+seconds;
}
currenttime = hour+":"+minutes+":"+seconds;
currentdate = todaydate+"/"+month+"/"+year;
fulldate = dayname+" "+todaydate+" "+monthname+" "+year;
delete timedate;
timedate = new Date();
}
哈哈!这样就可以了!