Chapter 9. Mouse Events

Mouse Events

Let’s explore Director’s sometimes counter-intuitive handling of mouse-related events. (See Chapter 2, for details on Director’s overall event handling and script creation.) This chapter is about understanding mouse event processing, not about creating buttons per se. Refer to Chapter 14, Graphical User Interface Components, in Director in a Nutshell for details on custom cursors and on creating well-behaved buttons and using the new Custom Button Editor Xtra. See also Example 4-6. “Manipulating Sprite Properties to Add Interactivity to a Button” in Chapter 4, CastLibs, Cast Members, and Sprites, in Director in a Nutshell.

Whenever the mouse button is pressed or released, Director generates mouseUp, mouseDown, rightMouseUp, or rightMouseDown events. Attach scripts with matching event handlers to turn the sprite into a clickable button.

Note that for simple linear presentations, the Tempo channel can be used to wait in a frame for a mouse click (or key press) before advancing the playback head. In prior versions of Director, the Tempo channel would ignore mouse events while waiting for time to elapse or for a sound or digital video to play. This limitation has been removed in Director 6 (although the Tempo channel doesn’t work in Shockwave).

Tip

The new mouseEnter, mouseLeave, and mouseWithin events are sent when the cursor enters or leaves a sprite with a corresponding handler attached (no mouse click is required). Leave the idleHandlerPeriod at its ...

Get Lingo in a Nutshell 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.