Skip to main content
January 16, 2008
Answered

Rotation / Jogdial

  • January 16, 2008
  • 1 reply
  • 368 views
Hi there!

I´ve already posted this topic on a german forum but nobody could help and i´m a bit of frustrated :)

In Flash CS3 i created a knob/dial which uses an own class called Drehrad. This class is stored in a file Drehrad.as.
With the Code in the maintimeline i create a new instance on the stage and in the
follwing Drehrad.as file the functionality is "born".

So far so good :)

The problem is the rotation. I only want the dial to rotate the direction the mouse moves but it won´t work.
It rotates ok, but i made a second ellipse on the dial (inside the movieclip Drehrad, which should be something like a thumb...) and this thumb should always point to the mouse direction.

I added a link to the swf and fla so that you can see the problem.

Drehrad_Test.zip

It seem´s, that the mouse direction and the calculated angle differ...

Help would be great.

Thx in advance

Ingo
This topic has been closed for replies.
Correct answer Newsgroup_User
Ingo,

> It rotates ok, but i made a second ellipse on the dial (inside
> the movieclip Drehrad, which should be something like a
> thumb...) and this thumb should always point to the mouse
> direction.

Looks like you're very close. The only difference I see is an even 90
degs off. Change line 36 of your Drehrad class from this:

this.rotation = Math.atan2(yVar, xVar)*180/Math.PI;

to this:

this.rotation = Math.atan2(yVar, xVar)*180/Math.PI + 90;

... and the thumb always points to the mouse.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


1 reply

Newsgroup_UserCorrect answer
Inspiring
January 16, 2008
Ingo,

> It rotates ok, but i made a second ellipse on the dial (inside
> the movieclip Drehrad, which should be something like a
> thumb...) and this thumb should always point to the mouse
> direction.

Looks like you're very close. The only difference I see is an even 90
degs off. Change line 36 of your Drehrad class from this:

this.rotation = Math.atan2(yVar, xVar)*180/Math.PI;

to this:

this.rotation = Math.atan2(yVar, xVar)*180/Math.PI + 90;

... and the thumb always points to the mouse.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


January 17, 2008
Yes!

This did it, thx a lot!

CU

Ingo