Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Atan2() function for ActionScript 2.0

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
5,831
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Feb 23, 2007

Keehun Nam describes how to use the Atan2 Function which is useful for rotating things according to the cursor location...

Sorry guys, I forgot to turn the cursor on!
If you need to rotate a movieclip according to the mouse, just copy the code and it will work!

Category:

Howto & Style

Tags:

License:

Standard YouTube License

  • likes, 4 dislikes

Link to this comment:

Share to:

Uploader Comments (knvb1123)

  • No problem

  • no comprendo.

    yo no hablo español

    Gracias

  • it seemed at parts like you hadnt thought the whole thing through but it was very useful and informative and good topic. i was jes wonderin' howd yall learnt this?

  • Yes. Indeed, it was my first tutorial and I really didn't know how to make these. But thanks so much for these complements! I hope to get bettere at creating tutorials over this summer. Thanks!

    And how did i know this? Well if a 14 year old "nerd" gets stuck with a computer, he's got to do something... :D

  • Hello.

    This is the person who made the tutorial...

    Thanks for your reply!

    This is my first tutorial... You can tell!

    And sorry for not showing the cursor, I was not aware of it until I was done...

    Just make sure you have all the AS down right and have centered BOTH vertically and horizontally of the arrow.

    Thanks

    Keehun Nam

see all

All Comments (24)

Sign In or Sign Up now to post a comment!
  • Thanks !!!

  • Oh and by the way, I suck at programming so please be gentle! Lol!

  • Hi there, how can I convert actionscript 2.0 to actionsript 3.0? I´ve tried changing it using flash decompiler eltima but I can't see the option to do so. Can you please give me some headlights?

  • @TheJunkieBox

    atan2 is a function which takes parameters x and y and returns an angle in radians.

    Basically if you know the x distance and y distance between 2 things, you put them into atan2 and it gives you the angle that 1 thing would need to turn to face the other. Useful for making things look/point at other things or shoot at them.

    Radians are a unit of angle (like degrees). To convert radians to degrees, multiply your radians by 180/pi.

  • I wish you'd have gone more in-depth. Perhaps you could have explained what exactly atan2 is, what a radian is for those who don't know, etc.

  • really helpful......

    thanks...

  • I got a little confused when you yourself were getting confused, but overall this was really helpful. Thank you! :]

  • Do you know hot to make a movieclip when is being in hitTest to play a sound???

    I tryed this: if(_root.mpla.hitTest(this)){l­oad(Sound)}

    but didn't worked.. Do you know the code for playing sounds?

  • To avoid it automatically pointing at the cursor you need to offset the rotation with the starting angle so that the object doesn't jump to the angle of the mouse location.

    So, if the object is at a rotation of 15 degrees already, you need to subtract the difference between the mouse angle and the original rotation angle e.g. mouse is at 90 degrees, offset by (90 - 15) 75.

    90 - 75 = 15

    If you then move the mouse to 95 degrees, the object is rotated to an angle of 20 degrees.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more