Chapter14.Events


Chapter 14. Events

IN THIS CHAPTER

  • Handling Events

  • Button Events

  • Movie Clip Events

  • Events of the Mouse Object

  • Events of the Key Object

  • Events of the TextField Object

  • Cross-Object Events

Back in Chapter 8, "Welcome to ActionScript 2.0," we went over the three basic elements that all objects in Flash have:

  • Properties. Information about an object, held within the object.

  • Methods. These are the "verbs" of objects; they are what the object does.

  • Events. Events tell Flash when something has occurred with that object.

For instance, with a movie clip, here are the three elements:

  • Property. _x

  • Method. gotoAndPlay(2)

  • Event. onEnterFrame

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:

  • "Let me know when she calls."

  • "Let me know when lunch is here."

  • "Let me know when the next meeting is."

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.




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net