Game Development Reference
Let's break this directive down into smaller pieces. The most important thing is this method call:
It's a method call to one of AS3.0's built-in methods. It's used to register the event so that the listener
can start its job.
At its most basic, the ]``ArajpHeopajan method call takes two parameters. In the example from
Figure 3-13, the parameters look like this:
The first parameter is the kind of event you're listening for. In this case, you're listening for mouse
clicks. The format for describing the kind of event to listen for is to use the imported event class
name, followed by a dot and then the event you're interested in:
The kind of event you want to listen for is the ?HE?G event. As I'm sure you can guess, it listens for
mouse clicks. (Events are always written in uppercase.)
The reason events are written in uppercase is because they're actually a programming
element called a constant . Constants are always written in uppercase, which is the
naming convention they follow. (You'll see how to use constants in Chapter 9.) The
?HE?G constant is built in to the AS3.0 IkqoaArajp class.
The second parameter is the function definition that you want to call when the event occurs. The
example used this one:
This is the name of the event handler. Its name must exactly match the name of the function definition
that contains the directives you want to run when the mouse button is clicked.
Using the event handler
This is what the event handler looks like in the example shown in Figure 3-13:
It's exactly like the function definitions that you looked at earlier in the section on methods. However,
there are two unique things about event handlers that distinguish them from ordinary function