3 Replies Latest reply on Feb 6, 2008 4:33 AM by tomellos

    Drag a movie according to a circle

    auit
      Hi there,
      I'm a newbie with Flash and I have a question, please help me !
      I have to make a clock which has 2 buttons: start and end. And user can control 2 buttons to get the start time and end time they want. I wrote this code to make the buttons can be draged and droped but I don't know how to let the buttons to be draged according to a circle of the clock.
      Please answer me as soon as you can because it's quite urgent.
      Thanks so much
      Thu.
        • 1. Re: Drag a movie according to a circle
          Level 7
          auit,

          > I'm a newbie with Flash and I have a question, please
          > help me !

          That's what the forums are for. :)

          > I have to make a clock which has 2 buttons: start and
          > end. And user can control 2 buttons to get the start
          > time and end time they want.

          Okay.

          > I wrote this code to make the buttons can be draged
          > and droped but I don't know how to let the buttons to
          > be draged according to a circle of the clock.

          Aha. Well, the startDrag() function, and its MovieClip.startDrag()
          method, don't much care *where* you drag a movie clip, only *that* you drag
          it. Actually, both the function and the method do allow you to constrain to
          a rectangle (see the optional parameters for either).

          > Please answer me as soon as you can because it's
          > quite urgent.

          Heh, I'm sure everyone who posts a question believes it to be urgent.
          ;) Let's see what we can do, here. It just happens that I recently blogged
          about how to constrain to a circle. I'm not sure your need is to constrain,
          per se -- it sounds as if you want to drag your movie clip on the edge of a
          circle only -- but if you piece through my sample code, you'll see that the
          answer to what you're after can be derived from the information presented.

          http://www.quip.net/blog/2006/flash/actionscript-20/how-to-constrain-circle

          Hint: you'll want to forego the if() statement and simply use the part
          that sets the MovieClip._x and MovieClip._y properties to the mouse's
          position.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Drag a movie according to a circle
            Level 7
            auit,

            > It just happens that I recently blogged about how to constrain
            > to a circle. I'm not sure your need is to constrain, per se --
            > it sounds as if you want to drag your movie clip on the edge
            > of a circle only -- but if you piece through my sample code,
            > you'll see that the answer to what you're after can be derived
            > from the information presented.

            Well, on second thought, the difference is probably too greate between
            what you want and what that other article illustrates. I wrote a new blog
            entry to handle your clock hand dragging. Check it out here. :)

            http://www.quip.net/blog/2006/flash/actionscript-20/how-to-drag-clock-hands


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Drag a movie according to a circle
              tomellos Level 1
              Needed this code and I found thanks to this forum and your good explanation. Also your blog is in my favourites from now.

              Thanks for share.
              Tomelloso