4 Replies Latest reply on Nov 14, 2008 10:09 PM by rlc5611

    trying to make a odometer move with the cursor

      im lookin to make an odometer move with a mouse on an axis and im havin a lil trouble its for a web site and its the navigation can some one plz help me?
        • 1. Re: trying to make a odometer move with the cursor
          Ned Murphy Adobe Community Professional & MVP
          Can you provide any specific info regarding what it's supposed to do, what you've done/tried, and what your having a problem with?
          • 2. Re: trying to make a odometer move with the cursor
            visions3000 Level 1
            ok well im in school for graphic design and me and my teacher was tryin to find a tut that explains how to do it so at home i tried to do like a mouse over kinda tut and that isnt wat i want. wat im lookin to do is this. you kno how a dash board is with the speedometer and all of that? well i have an interface where it is a dash and i want the speedometer to be the nav so u hav u kno home about me ect... and when u roll over the home i want the speedometer needle to follow the mouse. so the needle is gonna be on an axis so it only should go in a circle like a clock would. all i can find so far is preloaders so far still lookin. if u can help it will be greatly appreciated
            • 3. trying to make a odometer move with the cursor
              Ned Murphy Adobe Community Professional & MVP
              Odometer and speedometer, two very different animals, though they share the same vicinty on a dashboard. It was hard trying to visualize what you were trying to do with an axis for an odometer.

              One way to approach this is to control the _rotation property (angle relative to the normal position) of a needle movieclip. Create a new movieclip symbol and in it draw whatever you intend the needle to look like. Place the drawing such that the center of the movieclip stage is where you want the spinning axis of the needle to be. Your best bet might be to have it originally pointing in a direction relative to where the leftmost button will be so that you only have to deal with positive _rotation values. Place the needle mc on the stage where it's supposed to be and give it an instance name of needle.

              In the code for the buttons you want to change the _rotation value of the needle so that its angle changes.

              for this example the button will end up being rotated 25 degrees relative to the needle's normal rotation (which is 0 degrees):

              needle._rotation = 25;

              But that will make the needle immediately move to that angle in a flash... you won't see it gradually move there at all.

              So the better approach is to use a tween... use this in its place...

              new Tween(needle, "_rotation", Strong.easeOut, needle._rotation, 25, 2, true);

              needle._rotation: is the current rotation value
              25: is the ending rotation value
              2: is the time (sec) you want it to take to get there

              In order to use the tween you have to import the classes that support it, which is partly dependent on which version of Flash you're using, but this may work for you... search the Flash help docs regarding Tween if it doesn't

              import mx.transitions.Tween;
              import mx.transitions.easing.*;

              These two lines have to precede that line of code.

              Play with it.

              If you want the needle to actually follow the mouse movement, my approach would be too mathematical and I don't wanna spend time trying to explain it... it involves figuring out the angle of the mouse relative to the axis of the needle... but that approach wouldn't have the needle stopping at any buttons if you move the mouse away.