Chapter 16. Understanding Events
Introduction
In this chapter
Learning about the new event framework in AS3
Understanding the basics of event objects and event dispatchers
Understanding the Display List's event flow
ActionScript 3.0 adds a powerful framework for handling internal communication known as the event framework. Events are messages that are sent between objects when an action, such as a button click, has taken place. This enables you to create functionality that occurs sequentially without the need for the Flash Timeline or for complicated method calls to other classes.
The Flash Player 9 API uses events for many different purposes that were formerly handled in loose and inconsistent ways. Mouse actions, timers, networking, and asynchronous errors are all examples. We'll talk about how these subsystems use the event framework.
We'll take a look at how EventDispatcher
objects communicate and the structure of the new Event
objects. We'll also look at some of the more advanced features of the event framework, including how to create your own custom events and how to use the new event bubbling feature.
Introducing Events
What exactly is an event? At its core, an event is an object that represents an occurrence and describes the conditions surrounding that occurrence, including but not limited to, a description of the event, called the event type, and the origin of the event, also known as the event target.
This is by no means a new concept. In the past, ActionScript users have had ...
Get ActionScript™ 3.0 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.