在舞台上画线并行

时间:2014-11-15 11:46:49

标签: actionscript-3

如何在舞台的另一侧绘制相同的图片,如下例所示?

http://i.stack.imgur.com/JrkXA.png

这是我的代码:


var drawingLine:Sprite = new Sprite();
addChild(drawingLine);

 stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);


function mouseDownHandler(event:MouseEvent):void {
    timer.start();
    drawingLine.graphics.lineStyle(3, coloursArray[position]);
    drawingLine.graphics.moveTo(mouseX, mouseY);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}


function mouseMoveHandler(event:MouseEvent):void {
    drawingLine.graphics.lineTo(mouseX, mouseY);
}

 function mouseUpHandler(event:MouseEvent):void {
    timer.stop();
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}


function changeColour(e:TimerEvent):void{
    position++;

1 个答案:

答案 0 :(得分:0)

您可以使用copyForm method的{​​{1}}:

  

将源Graphics对象中的所有绘图命令复制到   调用Graphics对象。

一般表格:

  

destinationObject.graphics.copyFrom(sourceObject.graphics);

您的代码:

Graphics class