绘制一条线ActionScript 3不起作用

时间:2013-07-31 18:25:54

标签: actionscript-3 actionscript

大家好,我有一段代码用于绘制一条简单的线条,但如果有可能告诉我哪里是我的错误我会非常感谢!!!这是代码:

function click2(e:MouseEvent):void{
    e.currentTarget.removeEventListener(MouseEvent.CLICK, click2);
    fx=mouseX;
    fy=mouseY;
    var i:int;
    i=2;
    trace(i);
    trace(sx,sy);
    trace(fx,fy);
    var  line:Shape = new Shape();
    line.graphics.beginFill(0x0066FF);
    line.graphics.moveTo(400, 300);
    line.graphics.lineTo(400, 400);
    this.addChild(line);
}

非常感谢,我真的很感谢这个网站的社区,你们真的很帮助我看到我的错误,我m just a beginner but i做得很好,只是因为你心怀的人!!! p>

1 个答案:

答案 0 :(得分:2)

您正在绘制一条线,因此您必须设置lineStyle

function click2(e:MouseEvent):void {
    e.currentTarget.removeEventListener(MouseEvent.CLICK, click2);
    fx=mouseX;
    fy=mouseY;
    var i:int;
    i=2;
    trace(i);
    trace(sx,sy);
    trace(fx,fy);
    var line:Shape = new Shape();
    line.graphics.lineStyle(1, 0x0066FF, 1);
    line.graphics.moveTo(400, 300);
    line.graphics.lineTo(400, 400);
    this.addChild(line);
}