Skip to main content
Inspiring
July 9, 2008
Question

Tween on an Curve (k)

  • July 9, 2008
  • 3 replies
  • 258 views
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
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
July 10, 2008
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.
Inspiring
July 10, 2008
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;
> }
>
kglad
Community Expert
Community Expert
July 9, 2008
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).