Need script for circular animation with start and end angles

Discussion in 'JavaScript' started by James McMurray, Nov 19, 2007.

  1. #1
    I've got a background image that is a circle fivided into slices. The page will involve putting counters on various slices, and moving them around. I want to have a button that can grab all the pieces and move them by one slice.

    To do this, I need:

    1) The distance the object is from a specific point on the screen. I think my math skills are up to this.

    2) The angle of difference from the object's corner to the point. Again, I'm pretty sure I can figure out how to handle this.

    3) A function that can spin something x degrees in a counterclockwise circle using the radius and starting angle. For example: spinIt(radius, startAngle, endAngle). Animated movement would be nice, but is optional.

    It's that last part that I'm at a complete loss to do. I found a few scripts online that allow movement in a circle, and this one: http://webreference dot internet dot com/js/column18/circle.html is the only one I've found that uses all of the proper parameters, but I can't figure out how to get it to run consecutively.

    For example, the following two statements seem like they should combine to slide the object around from 0 degrees to 90, but don't.

    
      /*           radius, angle0, angle1, steps, interval, statement */
      anim1.circle(    85,      0,     45,     1,       5);
      anim1.circle(    85,     45,     90,     1,       5);
    
    Code (markup):
    Any used this script, or can see what I'm doing wrong?
     
    James McMurray, Nov 19, 2007 IP