1 Reply Latest reply on Oct 25, 2010 10:40 AM by Ned Murphy

    Follow Mouse AND set xy

    lkellis13

      Hello everyone!

       

      I hope someone can help me. I am making a vertical navigation bar where a rectangle follows the mouse. This is the code I put on the rectangle mc:

       

      onClipEvent (load) {

      _y = 0;

      speed = 5;

      }

      onClipEvent (enterFrame) {

      endY = _root._ymouse;

      _y += (endY-_y)/speed;

      }

       

       

      The only problem is that I want the rectangle to start at a certain point, then follow the mouse. Right now it just kind of flies in whatever direction.

       

      I want to do this to highlight the page they are on. So is they are on about, the second option down, I would like the rectangle to be behind the words about.

       

      Does that make sense?

       

      Thanks!

        • 1. Re: Follow Mouse AND set xy
          Ned Murphy Adobe Community Professional & MVP

          The code you show will make the rectangle follow the mousde as it moves up and down the stage, catching up to it gradually rather than instantaneously tracking the mouse movement.

           

          If you want the rectangle to move based on the selection of the menu, then you do not want the code you have shown.  The code you make will have to be relative to the use and position of the buttons, not the mouse movement.  So whatever code you have for clicking the buttons will trigeger the movement of the rectangle to the button, not moving the mouse.