ABSTRACT

If this explanation is confusing, don’t worry. A full understanding of the use of radians is not necessary to perform the math we need. In fact, there is a very handy constant in math that will help us convert between radians and degrees. It is known as pi (pronounced “ pie ” ); it is represented by the symbol π and is a nonrepeating decimal number approximately equivalent to 3.141. It represents the number of radians in a triangle, or half the number of radians in a circle; therefore, 180 ° is equal to π radians. To convert between radians and degrees, we simply multiply the number of radians by 180/ π or the number of degrees by π /180. Returning to our ActionScript example from above, the next line of code does just that, using the Math.PI constant:

If you test this FLA fi le you will see that the pointer consistently points in the direction of your cursor as you move it around the screen. Now that we have this piece of functionality in place, let’s add a layer of complexity. Suppose in addition to “ looking at ” the mouse we wanted the pointer to also move toward the mouse until it reaches the mouse’s x and y position. If you open the example MouseFollower.fl a , you’ll see how we can accomplish this.