Skip to main content
Participant
April 26, 2017
Question

Line following two constraints

  • April 26, 2017
  • 1 reply
  • 152 views

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.

thank you

    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    kglad
    Community Expert
    Community Expert
    April 27, 2017

    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++;

        }

    }