Skip to content

graphics.moveTo doesn't work in this situation #144

Description

@PeterKop

Hi, when i'm trying to draw a line by mouse, i code like this:

_s = new Shape();
_s.graphics.lineStyle(1, 0x00ff00);
addChild(_s);
stage.addEventListener(TouchEvent.TOUCH, onTouch);

private function onTouch(e:TouchEvent):void {
var touch:Touch = e.getTouch(stage);
if(touch) {
switch(touch.phase) {
case TouchPhase.BEGAN:
_s.graphics.moveTo(touch.globalX, touch.globalY);
break;
case TouchPhase.MOVED:
_s.graphics.lineTo(touch.globalX, touch.globalY);
break;
}
}
}

but i found _s.graphics.moveTo(touch.globalX, touch.globalY); doesn't work, when i press down mouse expect the first time. and the lines will link together.
is there anything wrong with my code?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions