Behavior Handler's fireEvent Method
You can pass two parameters from a scriptlet back to its host document : the event name and the event object. You trigger this exchange with the
BehaviorID prefix is omitted, the default behavior (as specified in the Behavior-type
Implements statement) is used.
eventName parameter above is the name of the event as defined in the Behavior-type
Implements section of the scriptlet. In our Connect Three game, this section looks like this:
<IMPLEMENTS ID="kuku" TYPE="Behavior" DEFAULT> <EVENT NAME="onBoxLoad"/> <EVENT NAME="onBoxClick"/> </IMPLEMENTS>
We fire this events from inside the
and at the end of the
The second parameter of
fireEvent() method is optional. It is an object that you can create inside the scriptlet (see previous page) and then read its properties back at the host document. As shown above, we transfer the
clickEvent object and the
loadEvent object to the calling page. These objects contains some context information related to the events. In case of the
clickEvent, the host page needs to know the ID of the box clicked and the shape of the piece last placed. In case of the
loadEvent, the host page needs to know the ID of the box loaded.
As explained in previous page, the event object fired by
fireEvent() (the second parameter) is accessed from the host page via the
window.event object. Notice that the
window.event object always points to the latest object fired outside the page.
Created: August 11, 1998
Revised: August 11, 1998