为什么我写单独一个小球跳动就可以显示,写多个小球之后,加上判断时分秒有无变化、添加彩色小球的代码之后,倒计时就不动了?我用NetBeans写的。
function update(){
var nextShowTimeSeconds=getCurrentShowTimeSeconds(); //下一个变化的时间
var nextHours = parseInt( nextShowTimeSeconds / 3600);
var nextMinutes = parseInt( (nextShowTimeSeconds - nextHours * 3600)/60 );
var nextSeconds = nextShowTimeSeconds % 60;
var curHours = parseInt( curShowTimeSeconds / 3600); //当前时间
var curMinutes = parseInt( (curShowTimeSeconds - curHours * 3600)/60 );
var curSeconds = curShowTimeSeconds % 60;
if(nextSeconds!==curSeconds){
//加入以下if之后时间静止不刷新
if(parseInt(curHours/10)!==parseInt(nextHours/10)){ //对小时的变化判断
addBalls(MARGIN_LEFT+0,MARGIN_TOP,parseInt(curHours/10));
}
if(parseInt(curHours%10)!==parseInt(nextHours%10)){
addBalls(MARGIN_LEFT+15*(R+1),MARGIN_TOP,parseInt(curHours%10));
}
if(parseInt(curMinutes/10)!==parseInt(nextMinutes/10)){//对分钟的变化判断
addBalls(MARGIN_LEFT+39*(R+1),MARGIN_TOP,parseInt(curMinutes/10));
}
if(parseInt(curMinutes%10)!==parseInt(nextMinutes%10)){
addBalls(MARGIN_LEFT+54*(R+1),MARGIN_TOP,parseInt(curMinutes%10));
}
if( parseInt(curSeconds/10) !== parseInt(nextSeconds/10) ){
addBalls( MARGIN_LEFT + 78*(R+1) , MARGIN_TOP , parseInt(curSeconds/10) );
}
if( parseInt(curSeconds%10) !== parseInt(nextSeconds%10) ){
addBalls( MARGIN_LEFT + 93*(R+1) , MARGIN_TOP , parseInt(nextSeconds%10) );
}
if( parseInt(curSeconds%10) !== parseInt(nextSeconds%10) ){
addBalls( MARGIN_LEFT + 93*(R+1) , MARGIN_TOP , parseInt(nextSeconds%10) );
}
curShowTimeSeconds=nextShowTimeSeconds;
}
updateBalls();
}
相关分类