3 Replies Latest reply on Jul 10, 2008 8:40 AM by kglad

    Tween on an Curve (k)

    Level 7
      I know this can be done because I've done it before, but I cannot find
      the file since it was around 6 or 7 years ago.

      I want to tween an object on half circle arch. Needs to be ActionScipt.

      I know it has something to do with sin and cosin, but beyond that I
      cannot remember.

      I don't think it a true Tween class, but maybe some sort of loop.

      Actually, I'll take any solution you can give.

      -Kirk
        • 1. Re: Tween on an Curve (k)
          kglad Adobe Community Professional & MVP
          this is from a CurveTo class that i wrote a while ago. you can use easing if you want to call the following function repeatedly passing a parameter t that can vary from 0 to 1 and defining the other obvious parameters (_loops = number of complete loops, _xAx = x-radius, _yAx = y-radius (these should be equal for a cirle), _fx = x-center, _fy = y-center).

          • 2. Re: Tween on an Curve (k)
            Level 7
            Thanks for the code. It's a little advanced for me.

            To try it, I made a movieClip and put it on the stage and called it "_tgt"

            Then I made an Actions layer and put the following in there:
            _loops=3
            t=1
            _xAx=30
            _yAx=30
            function ellipseF(t) {
            var ang:Number = t*Math.PI*2*_loops;
            _tgt._x = _fX+Math.cos(ang)*_xAx;
            _tgt._y = _fY+Math.sin(ang)*_yAx;
            }


            When I test it, nothing happens.


            kglad wrote:
            > this is from a CurveTo class that i wrote a while ago. you can use easing if
            > you want to call the following function repeatedly passing a parameter t that
            > can vary from 0 to 1 and defining the other obvious parameters (_loops = number
            > of complete loops, _xAx = x-radius, _yAx = y-radius (these should be equal for
            > a cirle), _fx = x-center, _fy = y-center).
            >
            >
            >
            > function ellipseF(t){
            > var ang:Number = t*Math.PI*2*_loops;
            > _tgt._x = _fX+Math.cos(ang)*_xAx;
            > _tgt._y = _fY+Math.sin(ang)*_yAx;
            > }
            >
            • 3. Re: Tween on an Curve (k)
              kglad Adobe Community Professional & MVP
              you must call ellipseF(t) repeatedly and pass t as it varies from 0 to 1 (if you want _tgt to complete 3 loops around your circle) and you need to define the circles center, _fx,_fy.