Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / July 2008



Tip: Looking for answers? Try searching our database.

Tween on an Curve (k)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
W. Kirk Lutz - 09 Jul 2008 20:49 GMT
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
kglad - 09 Jul 2008 22:15 GMT
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;
    }
W. Kirk Lutz - 10 Jul 2008 15:10 GMT
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.

> 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
[quoted text clipped - 7 lines]
>          _tgt._y = _fY+Math.sin(ang)*_yAx;
>      }
kglad - 10 Jul 2008 16:40 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.