Skip to main content
Participant
August 12, 2006
Question

Drag a movie according to a circle

  • August 12, 2006
  • 3 replies
  • 360 views
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.
This topic has been closed for replies.

3 replies

Participant
February 6, 2008
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
Inspiring
August 16, 2006
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."


Inspiring
August 12, 2006
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."