发新话题
打印

怎么清除AS画线?

怎么清除AS画线?

我用FLASH AS写了一个画线的AS,在执行擦除时,每次只能擦掉一条线,如果想一次擦完,应该怎么办?请教各位大师,先谢了。
源程序如下:
var lines = new XML("<?xml version=\"1.0\" standalone=\"no\"?><lines></lines>");
var num = 0;
function DrawLine(id, depth, x1, y1, x2, y2) {
      this.createEmptyMovieClip(id, depth);
      with (this[id]) {
              lineStyle(1, 0x000000, 100);
              moveTo(x1, y1);
              lineTo(x2, y2);
      }
}
this.onMouseDown = function() {
      dragging = true;
      startpointx = _xmouse;
      startpointy = _ymouse;
      moved = false;
};
this.onMouseUp = function() {
      dragging = false;
      if (moved) {
              tempnode = new XML("<line x1=\""+startpointx+"\" x2=\""+_xmouse+"\" y1=\""+startpointy+"\" y2=\""+_ymouse+"\"></line>");
              lines.childNodes[0].appendChild(tempnode);
              trace(lines.toString());
              lines = new XML(lines.toString());
              num += 1;
              moved = false;
      }
      moved = false;
};
this.onMouseMove = function() {
      moved = true;
      if (dragging) {
              DrawLine("line"+num, num, startpointx, startpointy, _xmouse, _ymouse);
      }
      updateAfterEvent(this.onMouseMove);
};
undo.onPress=function(){
      dragging=false;
}
redo.onPress=undo.onPress
undo.onRelease = function() {
      moved = false;
      num--;
      removeMovieClip("line"+num);
};
redo.onRelease = function() {
      moved = false;
      startpointx = lines.childNodes[0].childNodes[num].attributes.x1;
      startpointy = lines.childNodes[0].childNodes[num].attributes.y1;
      endpointx = lines.childNodes[0].childNodes[num].attributes.x2;
      endpointy = lines.childNodes[0].childNodes[num].attributes.y2;
      DrawLine("line"+num, num, startpointx, startpointy, endpointx, endpointy);
      num++;
};

TOP

TOP

用clear();就可以了

TOP

发新话题