collision detection.
A translation of the tutorial posted on actionscript.org