Wondering if anyone sees an issue with this code/approach?  I am trying to draw 
a line with the mouse and have the line follow the mouse, rather than a pen 
tool. This code sort of works, but if you move the mouse to fast or once in a 
while the line seems to get lost or detached.

private function drawFakeLine(  ) : void
                {
                        
                        var canvas:Sprite = new Sprite(); 
                        vis.marks.addChildAt( canvas, 0 ); 
                        
                        vis.addEventListener(MouseEvent.MOUSE_MOVE, draw_line);
                        vis.addEventListener(MouseEvent.MOUSE_UP, 
stop_drawing); 
                        
                        var startX:Number = vis.mouseX;
                        var startY:Number = vis.mouseY;
                        
                        canvas.graphics.moveTo(vis.mouseX, vis.mouseY);
                        
                        function stop_drawing(e:MouseEvent):void { 
vis.removeEventListener(MouseEvent.MOUSE_MOVE, draw_line) }; 
                        function draw_line(e:MouseEvent):void 
                        { 
                                canvas.graphics.clear();
                                canvas.graphics.moveTo( startX, startY );
                                canvas.graphics.lineStyle(1, 0xFF6633);     
                                canvas.graphics.lineTo(vis.mouseX, vis.mouseY); 
    
                                e.updateAfterEvent(); 
                        }
                }

Reply via email to