flash 电子时钟
flash 电子时钟,下面是时钟代码,图片各位朋友做0-9得就OK了.
onEnterFrame = function () {
var my_dateate = new Date();
//秒
var miao:Number = my_date.getSeconds();
if (miao<10) {
_mc2.gotoAndStop(1);
_mc1.gotoAndStop(miao+1);
} else {
_mc2.gotoAndStop(Math.floor(miao/10)+1);
_mc1.gotoAndStop((miao-Math.floor(miao/10)*10)+1);
}
//分
var fen:Number = my_date.getMinutes();
if (fen<10) {
_mc4.gotoAndStop(1);
_mc3.gotoAndStop(fen+1);
} else {
_mc4.gotoAndStop(Math.floor(fen/10)+1);
_mc3.gotoAndStop((fen-Math.floor(fen/10)*10)+1);
}
//时
var shi:Number = my_date.getHours();
if (shi<10) {
_mc6.gotoAndStop(1);
_mc5.gotoAndStop(shi+1);
} else {
_mc6.gotoAndStop(Math.floor(shi/10)+1);
_mc5.gotoAndStop((shi-Math.floor(shi/10)*10)+1);
}
//星期
var xingqi:Number = my_date.getDay();
_mc7.gotoAndStop(xingqi+1);
if (xingqi == 0) {
_mc7.gotoAndStop(xingqi+8);
}
//日
var ri:Number = my_date.getDate();
if (ri<10) {
_mc9.gotoAndStop(1);
_mc8.gotoAndStop(ri+1);
} else {
_mc9.gotoAndStop(Math.floor(ri/10)+1);
_mc8.gotoAndStop((ri-Math.floor(ri/10)*10)+1);
}
//月
var yue:Number = my_date.getMonth()+1;
if (yue<10) {
_mc11.gotoAndStop(1);
_mc10.gotoAndStop(yue+1);
} else {
_mc11.gotoAndStop(Math.floor(yue/10)+1);
_mc10.gotoAndStop((yue-Math.floor(yue/10)*10)+1);
}
//年(此句代码由终极老师指教)
var nian:Number = my_date.getFullYear();
for (var p:Number = 0; p<nian.toString().length; p++) {
_p = Number(nian.toString().charAt(p));
this["_mc"+(15-p)].gotoAndStop(_p+1);
}
/*(此句由本人所写,与上面效果一样,但上面的更简洁明了)
var nian:Number = my_date.getFullYear();
nian1 = Math.floor(nian/1000);
nian2 = Math.floor((nian-nian1*1000)/100);
nian3 = Math.floor((nian-nian1*1000-nian2*100)/10);
nian4 = Math.floor(nian-nian1*1000-nian2*100-nian3*10);
_mc15.gotoAndStop(nian1+1);
_mc14.gotoAndStop(nian2+1);
_mc13.gotoAndStop(nian3+1);
_mc12.gotoAndStop(nian4+1);
*/
};
补充:flash教程,动画技术