Prototype
Public override function addeventlistener (type: String, listener: function, usecapture: Boolean = false, priority: Int = 0, useweakreference: Boolean = false): void
Function
Listen for events and process corresponding functions.
Parameters
1. Type: String event type. 2. Listener: the function that listens to event post-processing events. This function must accept the event object as its unique parameter and cannot return any results, as shown in the following example: access modifier function name (EVT: Event): void 3, usecapture: boolean (default = false) involves the concept of "event stream. The listener has three phases: capture, target, and bubble. The sequence is: capture stage (check whether the listening function is called from the root node to the subnode) → target stage (Target itself) → bubble stage (the target itself to the root node ). The parameters here determine whether the listener is running in the capture, target, or bubble phase. If usecapture is set to true, the listener only processes events in the capture phase, rather than events in the target or bubble phase. If usecapture is false, the listener only processes events in the target or bubble phase. To listen for events in all three phases, call addeventlistener twice, set usecapture to true at one time, and set usecapture to false at the second time. 4. Priority: Priority of the INT (default = 0) event listener. The priority is specified by a signed 32-bit integer. The greater the number, the higher the priority. All listeners with a priority of N are processed before the listeners with a priority of n-1. If two or more listeners share the same priority, they are processed in the order they are added. The default priority is 0. 5. useweakreference: Boolean (default = false) determines whether the listener references a strong or weak reference. Strong reference (default value) prevents your listener from being recycled as garbage. Weak references do not have this function.
Edit note
Use the eventdispatcher object to register an event listener object so that the listener can receive Event Notifications. You can register an event listener on all nodes in the display list for specific types of events, phases, and priorities. After an event listener is successfully registered, you cannot change its priority by calling addeventlistener. To change the priority of the listener, you must first call removelistener (). Then, you can use the new priority to register the listener again.
Edit this example
Add listening event function go (){//...} document. getelementbyid ("testbutton "). addeventlistener ("click", go, false); or listener is the function document. getelementbyid ("testbutton "). addeventlistener ("click", function (){...}, false); Delete the event document. getelementbyid ("testbutton "). addeventlistener ("click", go [1]);