Flash Tutorial: Circle collisions

Flash tutorial describing how to set collisions with 2 circles using ActionScript 2.0 or ActionScript 3.0.

Editor’s review:

A lot of people use Flash’s hitTest() method for setting up collisions between 2 symbols, which is great, except when using on circles, hit test takes the outer dimensions of the entire symbol (a square), so it’s not an exact collision. This short Flash tutorial describes how to set up collisions of 2 circles where the collision is the curve lines of the circles rather than the symbol area. Pretty neat!

Also, nice explanation of the code accompanied by a short trigonometry lesson. But don’t worry, you don’t need to know trigonometry to complete this tutorial, it just helps explain what the code is doing.

ActionScript 2.0 and ActionScript 3.0 code is provided, although I couldn’t get the ActionScript 3.0 code to work correctly. Also, be careful when doing a copy/paste, as the AS2.0 code uses the HTML code for the less than symbol (”&lt;” vs “<”) on line 10. User will need to swap in the less than symbol if doing a copy and paste. Otherwise, the AS 2.0 code worked great!

View Tutorial: Flash Tutorial: Circle Collisons

Additional Info
Version: All
ActionScript: 2.0 and 3.0 code provided (note: editor could not get 3.0 code to work properly)
Online example: Yes
Source files available: No
Video Tutorial: No


About this entry