O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Trapping Events with Scripts

Each Director event is usually sent to the scripts in the following order, but there are a lot of exceptions, as noted below:

  1. Primary event handler(s)

  2. Sprite Behavior(s) and cast script(s)

  3. Frame script of current frame

  4. Movie scripts

Tip

Director 6 added many new events that are broadcast to both sprite scripts and the frame script in the current frame. Sprite scripts can prevent events from reaching cast scripts, and frame scripts can prevent events from reaching movie scripts.

Score events (such as exitFrame) are broadcast to all sprites and the frame script. Sprite events (such a beginSprite) are sent to whatever sprite span(s) or frame script span begins or ends in a frame. Mouse events (such as mouseUp) are generally sent to only one sprite at a time and only passed the frame scripts if not trapped by a sprite.

Let’s examine what happens in detail at each of these levels:

Primary Event Handler

If a primary event handler is defined, it receives the event first. By default, it passes the message onto other scripts rather than consuming it.

Sprite Behaviors (Sprite Scripts) and Cast Scripts

Many sprites have no scripts attached, and some have multiple scripts attached. Even sprites with scripts may ignore most events, trapping only those of interest. Refer to Chapter 9 for many more details on how sprites trap mouse events. For this discussion, you need only understand that mouse events are sent only to the first sprite that traps them.

Tip

If the member of sprite ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required