Chapter 14. EventsIN THIS CHAPTER
Back in Chapter 8, "Welcome to ActionScript 2.0," we went over the three basic elements that all objects in Flash have:
For instance, with a movie clip, here are the three elements:
This chapter goes into more detail about the third thing that objects have, events. An event, simply put, is when something happens. Every day you go through several hundred events. Every time you get email, that is an event. When you eat lunch, that's another event. And when you go home on Friday, you know that's an event. So you see, events happen all the time in almost everything we do. So what's the big deal with events? Well, events in Flash are used to tell us when something occurs so that we can run a certain block of actions or go to a certain frame in the movie. To put it in real-world terms, sometimes people want to be notified when a certain event happens. For instance:
These are just a few events that people want to be notified about in everyday life. When these events occur, the individual who is notified will do something about it. For instance, if someone is notified when lunch arrives, that person will probably want to eat it. This is what that event would look like in ActionScript: onLunchArrival = function(){ eatLunch(); } That looks simple enough, and it is. In Flash, you have events, which we will cover in detail throughout this chapter, that you might want your movie or application to listen for so that it will know when to execute a block of code. But before we cover some of the events of different objects, it's important to know how to handle these events in Flash when they occur. |