4 Replies Latest reply on Dec 14, 2008 8:23 PM by rlc5611

    Circular Slider


      I am creating a circular slider for my application.
      This particular slider controls the rotation of an object.

      It works great, but it only rotates the object in one direction, "clockwise".
      So regardless of which direction you move the slider, it only goes one way.
      Below is the code I am currently using to rotate the object.

      In order to rotate the object in both directions,
      I know that I need to assign a variable like "clockwise" to the slider.
      So that when i move the slider "counterclockwise" for example, and clockwise==false, it rotates the object in the opposite direction or "counterclockwise".

      My question is,
      How can I define when the variable "clockwise" will be equal to true or false?

      Thanks for any help that you can provide.

        • 1. Re: Circular Slider
          Ned Murphy Adobe Community Professional & MVP
          You might be able to use deltaX (current position - previous position). I haven't thought it thru entirely, but it may be worth thinking thru...

          For a clockwise direction, deltaX is positive while y is greater than some value, and negative when y is less that value (that y value being the half circle horizontally). I'm not sure if there'd be a glitch to deal with when you cross that border.

          Another approach could be to center the slider circle at a 0,0 relative point, and measure the angle of the slider control relative to that center, and just make the object you are rotating have that angle.
          • 2. Re: Circular Slider
            rlc5611 Level 1
            Not exactly sure I can picture what you are doing but I took this from an old script
            • 3. Re: Circular Slider
              americancuervo Level 1
              rlc5611, you are AWESOME!!!

              That is exactly what I am looking for.

              Thanks very much.
              • 4. Re: Circular Slider
                rlc5611 Level 1
                I was just looking at that script and I couldn't figure out why it worked. In my original file, my "slider" was initially pointing to the right. In what I gave you, I made the marker on top. Flash rotation begins at horizontal - not vertical so that marker dot is initially at -90 degrees. In that case, the script is much simpler and you don't need the initialization variables. In my original case, since my 0 degrees was truly horizontal, my conditional had to check for more possibilities. But to simplify what I gave you would be: