3 Replies Latest reply on Oct 29, 2007 10:53 AM by shasmith

    Rotate on startDrag () function

    DJ_Sick_Nick
      how can I make an MC rotate when I use the on (press) with the this.startDrag() function? I have tried many different ways of doing this, but all that happens is... nothing at all. I've tried fitting in the _rotation and the rotate command, but all fails. Please help me. Thanks in advanced.
        • 1. Re: Rotate on startDrag () function
          Level 7

          "DJ Sick Nick" <admin@freeusgaming.com> wrote in message
          news:eevc0h$ldm$1@forums.macromedia.com...
          > how can I make an MC rotate when I use the on (press) with the
          > this.startDrag()
          > function? I have tried many different ways of doing this, but all that
          > happens
          > is... nothing at all. I've tried fitting in the _rotation and the rotate
          > command, but all fails. Please help me. Thanks in advanced.
          >

          assuming the instance name of your draggable mc is "drag_me" you could do:

          ///////////////////////////////////

          drag_me.onPress = function() {
          this.startDrag(false);


          //Not necessary, but may give you some values to help with rotation
          below.
          // These are just the values of the cursor when you first press the
          button.
          var startX:Number = _root._xmouse;
          var startY:Number = _root._ymouse;

          this.onMouseMove = function() {
          //Again, not necessary, but now you can compare the values of the
          start and current every frame.
          var currentX:Number = _root._xmouse;
          var currentY:Number = _root._ymouse;

          //maybe use the differences between currentX and startX (and Ys) to
          do some rotation.

          this._rotation = ..... ? ......
          };
          };


          drag_me.onRelease = function() {
          stopDrag();
          this.onMouseMove = undefined;
          }

          /////////////////////////////////////

          or, if you just want it to start rotating, regardless of position, you could
          try:

          //////////////////////////////////

          drag_me.onPress = function() {
          this.startDrag(false);
          this.onEnterFrame = function() {
          this._rotation += 1;
          }
          }

          drag_me.onPress = function() {
          stopDrag();
          delete this.onEnterFrame;
          }


          ////////////////////////////////

          Please note, no code above has been tested.

          SMB


          • 2. Re: Rotate on startDrag () function
            kglad Adobe Community Professional & MVP
            you need to initiate a loop that continually changes the _rotation property of your movieclip that you'll probably want to terminate in your on(release) handler.
            • 3. Re: Rotate on startDrag () function
              shasmith
              I tried the above code and couldn't get it to work. What did you end up doing?