Table of Contents### Calculating Distances with the Math Object

Entire Site

Using the Pythagorean theorem, Flash makes it possible for you to calculate the distance between two objects. This technique can be useful for creating novel interactions between interface elements—for example, graphics, buttons, or sounds that react in proportion to their distance from the viewer's pointer. You can also create games that have interaction based on the distance between objects and the player. For example, a game where the player uses a net to catch goldfish in an aquarium can use the distance between the goldfish and the net to model the behavior of the goldfish. Perhaps the closer the net comes to one, the quicker it swims away.

The distance between any two points is defined by the equation