System Events


As I mentioned earlier, events are either generated by the user or by Director. In the normal course of playing your movie, Director generates a number of events that you can either ignore or take advantage of by writing handlers. However, you'll need to know what these events are, and the order in which they happen if you're to use them properly.

There are nine events that Director will generate broken down as follows:

prepareMovie The very first event fired when the movie is played. To handle this event you need a handler placed in a movie script.

beginSprite Event two if there's a sprite on frame 1. Also happens whenever the playhead enters a new sprite span. This event can be handled by placing a handler within a sprite's behavior script.

stepFrame This is the third event and is special in that it can only be handled by an object on the actorList. You'll learn more about the actorList in Lesson 12.

prepareFrame Event four, generated for both sprite and frame scripts. The sprite receives the event before the frame. This event can be handled through a handler within a sprite's behavior or a handler within a frame behavior.

startMovie Event five. To handle this event you must place a handler within a movie script.

enterFrame Event six, generated for both sprite and frame scripts. The sprite receives the event before the frame. You can handle this event through a sprite behavior or a frame behavior.

exitFrame Event seven, generated for both sprite and frame scripts. The sprite receives the event before the frame. You can handle this event through a sprite behavior or a frame behavior.

stopMovie Event eight, generated when the movie stops play back. To handle this event you must place a handler within a movie script.

endSprite Event nine. When the movie stops this event is sent to the sprite after the stopMovie is generated. This event is also generated each time the playhead leaves a sprite span. Place a handler within a sprite's behavior script to handle this event.

Because it always helps to visualize something to learn it, included on the CD in the Lesson04 folder is a file named events.dir.

1.

Open events.dir from the Lesson04 folder on the CD. Make sure that Loop Playback is off under the Control menu and then open the Message window and play the movie.

When the movie is played you'll see a list of events appear in the Message window. These are, as you might've guessed, from trace() statements placed in each of the event handlers. You can see by the list in the Message window that the order of events matches the list given previously.

2.

Stop the movie and examine the three scripts in the cast.

The movie script in member 1 is a new script type that you'll become more familiar with as you progress through the book.

Now, let's move on to a brief discussion of Director's Object Model.



Macromedia Director MX 2004. Training from the Source
Macromedia Director MX 2004: Training from the Source
ISBN: 0321223659
EAN: 2147483647
Year: 2003
Pages: 166
Authors: Dave Mennenoh

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