Custom events and scheduled events
With the new version of WADE you can define your own custom events, simply by listening to them:
wade.addEventListener(object, 'myCustomEvent');
Then fire this event and the 'myCustomEvent' function of the listeners (or of any behaviors of the listeners) will be executed:
wade.processEvent('myCustomEvent');
But things get even more interesting as you schedule your custom events, so for example you could do this:
spaceship.schedule(1000, 'fire');
Which would cause the 'fire' function of the spaceship object to be executed after 1000 milliseconds, unless the spaceship is removed from the scene in the meantime, in which case the scheduled event is automatically cancelled.
|