A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Smoothing out Actionscript related movement

  1. #1
    Junior Member
    Join Date
    Jan 2001
    Posts
    3

    Post

    I seem to run into probems with choppineess when I change move a movie clip with action script.. here is an example..

    i have two mc's, A is stationary and B rotates around A.
    here's the action script:

    if (i == 360) { i = 0; }
    b._x = a._x + (120 * Math.cos(i));
    b._y = a._y + (120 * Math.sin(i));
    i = i + .05 ;
    gotoAndPlay(_currentframe

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    911
    Flash's math objects work in radians not degrees. Change your code to something like this:
    Code:
    trans = Math.PI / 180;
    if (i >= 360) 
          i = 0;
    b._x = a._x + 120 * Math.cos(i * trans); 
    b._y = a._y + 120 * Math.sin(i * trans);
    i += .05 ;
    Something like that should do the job.

    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center