1 Reply Latest reply on Apr 26, 2017 8:28 PM by kglad

    Line following two constraints

    johnw42782580

      Hello

      I'd like to create a line that follows two constraints:

      1. its pivot point is the line end which is fixed on a star

      2. the second end follows a path - an arc of a circle

      additionally, a small circles follows the same arc in the same pace.

      PATH.png

      thank you

        • 1. Re: Line following two constraints
          kglad Adobe Community Professional & MVP

          var p:MovieClip = new MovieClip();

          addChild(p);

          var ctr:Point = new Point(300,300);

          var perimeterPt:Point = new Point();

          var rad:int = 200;

          var angle:int = 270;

          var fac:Number = Math.PI/180;

          var t:Timer = new Timer(30,0);

          t.addEventListener(TimerEvent.TIMER,drawF);

          t.start();

           

           

          function drawF(e:TimerEvent):void{

              with(p.graphics){

                  clear();

                  lineStyle(0)

                  perimeterPt.x = ctr.x+rad*Math.cos(angle*fac);

                  perimeterPt.y = ctr.x+rad*Math.sin(angle*fac);

                  moveTo(pivot_mc.x,pivot_mc.y);

                  lineTo(perimeterPt.x,perimeterPt.y);

                  circle.x = perimeterPt.x;

                  circle.y = perimeterPt.y;

                  angle++;

              }

          }