home / experts / javascript / column23 |
|
Behaviors expose their custom events via the
Because the event element contains no child elements, the syntax above is equivalent to:
The event element is a child of the scriptlet's Behavior-type Imlements element. In our Connect Three example, we define two events. The onBoxLoad event is fired nine times, once for every box loaded in the game board. The onBoxClick event is fired whenever a player clicks an empty box. Here is the Connect Three example's Behavior-type Imlements element:
Let's see now how the calling page acts upon these events. In the Connect Three example, every box is a separate image to which the above two events are applied. Here is the top left box definition:
We can see that handlers for custom events are defined exactly as those for default intrinsic events, such as the For the event to be communicated to the containing page, the custom event needs to be fired in the scriptlet. In our example, the
Similarly, the
The meaning of the |
Created: August 11, 1998
Revised: August 11, 1998
URL: http://www.webreference.com/js/column23/event.html