Skip to main content
Inspiring
October 13, 2012
Question

Follow an object (mouse click) without decreasing the speed

  • October 13, 2012
  • 1 reply
  • 2160 views

hello,

i want to make a movie clip follow the mouse while we are pressing the left Button (NOT "be" the mouse ), i end it up with this code but am having a problem,

-the speed of the movie clip decrase by his own, i know that this is happening because of the last two lines, i will be glad if anyone could help me to solve this problem, thanx

onClipEvent (enterFrame) {

          onMouseUp = function ()

          {

                    apui = false;

          };

          onMouseDown = function ()

          {

                    apui = true;

                    rotateSpeed = 3;

          };

          if (apui == true)

          {

                    goX = _root._xmouse;

                    goY = _root._ymouse;

         

}

          else if (apui == false)

          {

                    goX = this._x;

                    goY = this._y;

          }

          this._x -= (this._x - this.goX)/20 ;

          this._y -= (this._y - this.goY)/20 ;

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 13, 2012

if you don't want that movieclip to ease into the mouse position, what do you want it to do?

Inspiring
October 13, 2012

no i want that but the thin is the speed is not constant, i want to found a solution for that 

thank you

kglad
Community Expert
Community Expert
October 13, 2012

that's because you're EASing the movieclip into the mouse position.  if you don't do that you must choose some other way to move the movieclip to your mouse position.

stating you want the movieclip to move at a constant speed is not enough information to determine the movieclip's movement.  how long between the start of mouse movement and the start of the movieclip's movement?  how long should it take for the movieclip to reach the mouse position?