Event propagation

How input events, such as clicks, propagate

When an input event is fired, it may be received by multiple objects, if they are on top of each other. The object that is on top is the first to receive the event, that propagates to all the objects below, down to the App object itself. Returning true in any of the event handling functions stops the event propagation.
App = function() { this.init = function() { // create a scene object to display some text this.textSprite = new TextSprite('Click right here', '32px Arial', 'red', 'center'); this.textObject = new SceneObject(this.textSprite); // define what happens when the text object is clicked this.textObject.onClick = function() { wade.app.textSprite.setText('Well done!'); // returning true here stops the event propagation // if you remove it, App.onClick() will be executed after this function return true; }; // add the object to the scene and listen for onClick wade.addSceneObject(this.textObject); wade.addEventListener(this.textObject, 'onClick'); }; this.onClick = function() { wade.app.textSprite.setText('I said right here'); }; };
Your code was executed successfully!