Events
Understanding events with Adobe Flash is an enormously important aspect of ActionScript development. To have control to deliver media rich content, ActionScript has to call on an Event. Events communicate between the Mouse, Keyboard and objects that need to share data.
With ActionScript 3.0 there are two distinct roles that are continuously in motion. Broadcasters and Listeners.
- Broadcasters – informs (tells) Flash what is going on with the Keyboard or the Mouse
- Listener – Objects that are missing for specific actions that might be broadcasted by the Mouse (keyboard)
Tutorial 1 – Event Handler
To explore the Broadcaster / Listener interaction, we will create a click handler that can respond to the mouse.
- Open Flash
- Create a New document 550 x 400 pixel / 30fps
- Save File > EventsHandler.fla
- Insert > New symbol
- Give the symbol the name: RedSquare
- Select MovieClip for type
- Click Export for ActionScript (RedSquare)
- Press OK
- If you receive an update message, confirm yes
- Add a small square to layer 1 (center to stage)
- Return to Scene 1
- Rename Layer 1 – Actions
- Lock Actions layer
- Save file – EventsHandler
- Select the first frame on the timeline
- Press F9 to open ActionScript panel
- Add the following lines of code: (test your movie)
var redSquare = new RedSquare();
redSquare.x = 50;
redSquare.y= 50;
addChild(redSquare);
redSquare.addEventListener (MouseEvent.MOUSE_DOWN,onClick)
function onClick(e:MouseEvent):void {
trace(“The square was clicked.”);
}
Upon testing, the movie the MovieClip calls from the Library by the Export ActionScript name “RedSquare” and is positioned 50 pixels right and 50 pixels down.
I want the square to respond to my mouse. For a response to happen in Adobe Flash, you first have to create a listener that will observe a particular device for events. In this case I what to observe what is happening with the mouse. More so, I want to listen for mouse clicking square.
To expand your mouse event to react when there is a mouse over event.

