3 Replies Latest reply on May 24, 2011 10:31 AM by jjk?aaa

    orbiting around a moving object

    jjk?aaa

      hi i have made a mc to circle around another mc (which is called a) which you can move

       

      but i do not know the code to make it follow orbiting the mc that can move. this is the code i have all ready

       

       


      this is on the dragiable mc this mc name is (a)

       

      on (press) {
          startDrag(this, false, 0, 23, 495, 407);
      }

       

      on (release) {
          stopDrag();
      }

       

      and then on the mc that is orbiting the other one

       

          onClipEvent (load) {
          var radius = 200;
          var speed = 5  ;
         
              var xcenter = _root.a._x ;
             
          var ycenter = _root.a._y ;
         
          var degree = 0;
          var radian;
      }
      onClipEvent (enterFrame) {
          degree += speed;
          radian = (degree/180)*Math.PI;
          this._x = xcenter+Math.cos(radian)*radius;
          this._y = ycenter-Math.sin(radian)*radius;
      }

       

      hope some one can help