用 Canvas=DDraw.DrawSurface; 方法来动态写字,为什么每次都要把以前写过的字重新写一遍呢?
具体代码:<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <script language="VBScript">
    </script>
    <script language="JavaScript">
 var interval=null;
        var loopFlag=0;
        var loopIndex=0;
        var arr=new Array(); //从文件中把坐标读到程序的数组里,文件里每一行有两个坐标x,y
 function IPoint(){
    this.x=0;
           this.y=0;
 }
 var i_x=0;i_y=0;
 var fso = new ActiveXObject("Scripting.FileSystemObject");
 var f = fso.OpenTextFile("C:/file/data1.txt",1);
        var iIndex = 0;
        while(!f.AtEndOfStream) {
     var s=f.ReadLine();
      var arrLL=s.split(/,/);
     var p=new IPoint();
     i_x=arrLL[0];
     i_y=arrLL[1];
     p.x=i_x;
     p.y=i_y;
     arr[iIndex]=p;
     iIndex++;
 }
 f.close(); //坐标以点的形式 画在DDraw里
 function lBegin(){
     //以前用setTimeout
     interval=window.setInterval('drawLine',50);
 } function drawLine(){
    creatLine(loopFlag);
           loopFlag++;
      if(loopFlag > arr.length-2){
        window.clearInterval(interval);
    }
 }//坐标以点的形式 画在DDraw里
  function creatLine(loopIndex){
     var x0=arr[loopIndex].x;
     var y0=arr[loopIndex].y;
     var x1=arr[loopIndex + 1].x;
     var y1=arr[loopIndex + 1].y;
     var Canvas=DDraw.DrawSurface;
     Canvas.Line(x0,y0,x1,y1);
     DDraw.DrawSurface = Canvas;  //每次都把以前画过得再生成一次,按道理应该只画本次循环生成的线
 }
    </script>
    </body>
    <input type="button" name = "Begin" value = "Begin" onClick = "lBegin()">    <object id=DDraw classid="clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6"         style="background:#FFFFFF;position:absolute;left:px;top:40px;width:500px;height:500px;>
    </object>   
</html>

解决方案 »

  1.   

    我运行了你的代码,有错误,你的    <object id=DDraw classid="clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6"         style="background:#FFFFFF;position:absolute;left:px;top:40px;width:500px;height:500px;>
        </object>  直接显示在画面上了,用的什么对象.
      

  2.   

    把<object id=DDraw classid="clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6"         style="background:#FFFFFF;position:absolute;left:px;top:40px;width:500px;height:500px;></object>换成<object id=DDraw classid="clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"        style="background:#FFFFFF;position:absolute;left:px;top:40px;width:500px;height:500px;>
        </object> 应该没有错误了 ,这是什么对象我也不太清楚。
    还有我这个代码里有个读文件的过程,大家应该没有那个文件,运行的时候注意了。谢谢了
      

  3.   

    提示这对象没有被声明
    还有你的OBJECT对象的代码直接显示在画面上了
      

  4.   

    少些个结束的双引号
    <object id=DDraw classid="clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"        style="background:#FFFFFF;position:absolute;left:px;top:40px;width:500px;height:500px;">
    就是直接显示在画面上的,运行起来就显示在上面的,这个有问题吗?