setTimeout时间参数设的稍大一些

解决方案 »

  1.   

    this.moveImplement= function()
    {
        alert("begin to start>>>");
        while(this.xpos < this.x2 || this.ypos < this.y2){ 
         this.xpos+=2;
         this.ypos+=2*(this.y2-this.y1)/(this.x2-this.x1);
         this.motodiv.style.left=this.xpos; 
         this.motodiv.style.top=this.ypos;
         setTimeout("??",1000);    
        }
    };
    ??这里怎么写?可以实现动画?
      

  2.   

    时间已经不是问题了~怎么写哪个EXPRESSION?
      

  3.   

    this.moveImplement= function()
    {
        alert("begin to start>>>");
    var self = this;
    var f = function(){self.move()};
        this.timer = setInterval(f,1000);    
    };
    this.move = function(){
    if(this.xpos >= this.x2 && this.ypos >= this.y2)
    {
    clearInterval(this.timer);
    return;
    }
    this.xpos+=2;
    this.ypos+=2*(this.y2-this.y1)/(this.x2-this.x1);
    this.motodiv.style.left=this.xpos; 
    this.motodiv.style.top=this.ypos;
    }