Events are sent to listeners that are executed by a touch on the mobile screen, tap, accelerometer, and so on. Functions or objects can be event listeners. When an event occurs, the listener is called by a table that represents the event. All events will have a property name that identifies the kind of event.
Display objects and global runtime objects can be event listeners. You can add and remove listeners for events using the following object methods:
object:addEventListener()
: This adds a listener to the object's list of listeners. When the named event occurs, the listener will be invoked and supplied with a table that represents the event.object:removeEventListener()
: This removes the specified listener from the object's list of listeners so that it is no longer notified of events that correspond to the specified event.
In the following example, an image display object registers to receive a touch event. Touch events are not broadcast...