1 Reply Latest reply on Jan 10, 2008 7:53 AM by visualmc

    Help with drawing curves

    visualmc
      I am currently running into a problem with drawing a curve from point A to point B and being able to drag either point while having Flash redraw the curve between the two points. I can get it to draw the curve and I am able to drag one point and Flash redraws the curve correctly. The problem is having both points dragable and keeping the curve updated.
        • 1. Re: Help with drawing curves
          visualmc Level 1
          function drawCord(col:String, tar:String, startX:Number, startY:Number):Void {

          //defines MovieClip to which cord attaches
          var target:MovieClip = this[tar+"Lead_mc"];

          //creates initial cord
          createEmptyMovieClip(tar+"Cord_mc",getNextHighestDepth());
          with (this[tar+"Cord_mc"]) {
          moveTo(startX,startY);
          lineStyle(6,col);
          curveTo(((target._x-startX)/2)+startX,target._y+200,target._x,target._y);
          }


          //defines press and release functions
          target.onPress = function():Void {

          startDrag(this);

          //redraws cord on MouseMove
          onMouseMove = function ():Void {
          var xPos:Number = target._x;
          var yPos:Number = target._y;
          createEmptyMovieClip(tar+"Cord_mc",this[tar+"Cord_mc"].getDepth());
          with (this[tar+"Cord_mc"]) {
          moveTo(startX,startY);
          lineStyle(6,col);
          curveTo(((xPos-startX)/2)+startX,yPos+200,xPos,yPos);
          }
          updateAfterEvent();
          };

          };

          target.onRelease = function():Void {
          this.stopDrag();
          delete onMouseMove;
          };

          target.swapDepths(getNextHighestDepth());
          }