A Flash Developer Resource Site

# Thread: [RESOLVED] Angle from 0,0 to x,y

1. ## [RESOLVED] Angle from 0,0 to x,y

As a beginner I'm thrashing out an application and I want to figure most of it out on my own. But being a math dork I can't figure out the equation (or function) that yields the angle of the line from 0,0 to the mouse x,y.

I want to click and drag the minute hand around a clock face.

Thanks.

2. Please see the attached FLA (F8).
Hope this is what you asked.

3. ## Thank you

Nice, just what I was looking for.

This is the part that is a little mysterious to me. Why choose "th" as a variable name? I guess I should pull a trig text and brush up on this. The whole radian to angle thing confuses me.

th=Math.atan2(yl,xl);
an=th*180/Math.PI;

Now to struggle with the rest.

4. For calculating the trigonometric functions FLASH requires that the angle should be in radians (th).
For using the _rotation function FLASH requires that the angle should be in degrees (an).
an=th*180/Math.PI;
I hope I could it make clear, otherwise please read a good book on trigonometry, and flash programming.

5. Eager Beaver-

Creative Action was confused by your variables' names. i assume by 'th' you're truncating 'theta' and by 'an' you're truncating 'angle.' It never hurts to be overly descriptive in your variable name- especially when the goal is to help someone out...

6. Thank you for your suggestion.
Yes, you are correct:
an==angle (degrees).
There are many abbreviations in the net nowadays.
LOL: Laugh Out Loud.
OMG: Oh My God.
ASAP: As Soon As Possible.
And so on.

7. Originally Posted by Eager Beaver
Yes, you are correct:
an==angle (degrees).
There are many abbreviations in the net nowadays.
LOL: Laugh Out Loud.
OMG: Oh My God.
ASAP: As Soon As Possible.
And so on.
abbreviation has its place...

8. I think you prefer to pick up an argument on this subject.
I thought there were no rules not to assign names such as, th, an, to variables.

9. Originally Posted by Eager Beaver
I think you prefer to pick up an argument on this subject.
no- just lulz
Originally Posted by Eager Beaver
I thought there were no rules not to assign names such as, th, an, to variables.
of course not- but if you want your code to be comprehensible, it's a different story. i mean why th? why stop there? why not t?
Originally Posted by Eager Beaver
the above would indicate otherwise, but time will tell!

10. Originally Posted by newblack
no- just lulz
of course not- but if you want your code to be comprehensible, it's a different story. i mean why th? why stop there? why not t?
the above would indicate otherwise, but time will tell!
Yes you can use t or th or the or thet or theta, and the FLA works without any problem.
I have already agreed with your suggestion to use variable names theta and angle so that Creative Action understands the CODE with ease.

11. Thank you Eager Beaver and newblack, th being Theta is exactly what I was looking for. The other abreviations were apparent to me. And I plead guilty to needing to read a Trig Text. Can you suggest a really good AS2 book? I'm considering Lynda.coms AS3 DVD, what do you think? Basically, I am always guilty of coming up with some overly complex project and then beating my head against it until I learn the program. My very first 3D modeling project was a pirate ship with everything.

12. I suggest for flash8, and AS2, flash bible.
I don't know AS3.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap