Table of Contents        Previous topic       Next topic       

Event Listening

Every object that generates events supports the two functions addEventListener() and removeEventListener().

Each of these functions takes three parameters.  The first parameter is a string representing the event name and the second parameter is the name of the event handler function.  The third parameter is not currently used and, for future compatibility,  should preferably be false.

So, to register the Javascript function afterStep as a listener for the afterstep event of the jState.core object you would use:

jState.core.addEventListener("afterstep", afterStep, false);

(The jState code creation wizards are able to generate the addEventListener() code for every supported event.)

To later deregister this Javascript function so that it is not longer called in response to the afterstep event you would use:

jState.core.removeEventListener("afterstep", afterStep, false);