An event listener “listens” for a specific event to happen. Most events involve either the mouse or the keyboard. For example MOUSE_DOWN listens for the left button on the mouse to be pressed.


Event listeners need to be attached to specific objects. A button, the stage or the whole movie are all objects that we can add an event listener to.  


Line Callout 2: Function to be called on the event Line Callout 2: Type of event to listen for Consider this Code:

Line Callout 2: Instance name of the button



playButton.addEventListener(MouseEvent.MOUSE_DOWN, playSong);



function playSong(event:MouseEvent):void {


    trace("The play button was pressed");




In this course we are going to primarily deal with Mouse and keyboard events as a way to interact with the user. But there is more to it, for a full description of event handling in ActionScript check out this article.


Important Notes:

1.    Any displayable object can have an event listener added to it.

2.    Event listeners are effective until they are removed using removeEventListener.