Mark is true. Respect! :-) I used Math.atan(), too and if/else to know, in which quadrant of the circle the drag element is moved.
I uploaded my quick&dirty source now. Please be kind! :-) http://lizu.net/circle.swf http://lizu.net/circleSrc.zip it consists of the circle drag mechanism, but I think, the scrolling can be easily applied then with a 'rule of three' and the angle. hth, Matthias 2007/5/23, Mark Winterhalder <[EMAIL PROTECTED]>:
On 5/23/07, Jesse Graupmann <[EMAIL PROTECTED]> wrote: > > Trigonometry No need, apart from Math.atan2() to get the result -- assuming the anchor point of the container is in the middle, just normalize the vector from the centre to the mouse and then scale it to the desired radius, that's the position of the handle. About like this: var xmouse = ... var ymouse = ... var radius = ... var magnitude = Math.sqrt( xmouse * xmouse + ymouse * ymouse ); var x = xmouse / magnitude * radius; var y = ymouss / magnitude * radius; var angle = Math.atan( ymouse, xmouse ); // devide by Math.PI * 180 if you wish // now set the position of the handle to x, y and broadcast an event with the angle. If you want to set it to a certain angle (in radians), it should be something like... var x = Math.cos( angle ) * radius; var y = Math.sin( angle ) * -radius; ...which might turn into the wrong direction or be set off by Math.PI/2, in that case, flip the sign of y and/or add/subtract Math.PI/2 to the angle. HTH, Mark _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com