1 Reply Latest reply on Apr 19, 2011 5:43 AM by Saraav m

    line drawing shows points !!

    Saraav m

      paste this code in the first frame of timeline .and press the mouse and try to drwa some line ,the line shows all the points .how to remove this points without increasing the alpha value. please help me.

       

      //---------------------------------------------------------------------------------------- --------------------//

       

      import flash.display.Sprite;

      import flash.display.MovieClip;

       

       

      stage.addEventListener(MouseEvent.MOUSE_DOWN,stageDownHandler);

       

      stage.addEventListener(MouseEvent.MOUSE_UP,stageUpHandler);

      var pts:Array = [];

       

      var canvas:Sprite = new Sprite();

      addChildAt(canvas,0);

       

      var g:Graphics = canvas.graphics;

      var prevMidpt:Point = null;

       

       

       

       

      function draw():void {

      g=canvas.graphics;

      g.clear();

       

      prevMidpt = null;

      var l:Number = pts.length;

      for (var i:Number=1;i<l;i++) {

       

       

      var pt1:Object = pts[i-1];

      var pt2:Object = pts[i];

       

      var midpt:Point = new Point(pt1.x+(pt2.x-pt1.x)/2,pt1.y+(pt2.y-pt1.y)/2);

       

      g.lineStyle(30,0x000000,0.4);

      //trace(prevMidpt);

      if (prevMidpt) {

      g.moveTo(prevMidpt.x,prevMidpt.y);

      g.curveTo(pt1.x,pt1.y,midpt.x,midpt.y);

      }

      prevMidpt = midpt;

      }

       

       

      }

       

       

       

      function stageDownHandler(e:MouseEvent) {

       

      stage.addEventListener(MouseEvent.MOUSE_MOVE,handleClick);

       

      }

      function stageUpHandler(e:MouseEvent) {

       

      stage.removeEventListener(MouseEvent.MOUSE_MOVE,handleClick);

       

      }

      function handleClick(evt:MouseEvent):void {

       

      var anchor:Sprite = new Sprite();

       

      anchor.x = mouseX;

      anchor.y = mouseY;

      pts.push(anchor);

       

      draw();

      //}

      }