Chapter 2. Events, Messages, and Scripts

Events and Messages

This chapter covers the foundation on which every Director project is built—interactivity. How does Director respond to user events? How can you control the flow of both Lingo and the Score? How does Director know which Lingo to execute? If you are new to Lingo, I explain everything in great detail below.

Users familiar with D5 should note these important changes in D6:

  • Score scripts are now instantiated and “know” who they are (they receive the me parameter indicating their script instance and, indirectly, their sprite number).

  • Sprites can have multiple scripts (Behaviors) attached, all of which can receive the same events. A sprite might have multiple mouseUp and mouseDown handlers in different attached Behaviors.

  • Behaviors are instantiated scripts that can have custom properties applied each time they are used in the Score. Multiple Behaviors can be “piled on” a sprite, allowing you to modularize your Behaviors. (One Behavior might have just a mouseUp handler, and one might have just a mouseDown handler). These factors can dramatically reduce the total number of scripts required.

  • A single frame script can span multiple frames in the script channel, just as sprites now span multiple frames.

  • Many new events are broadcast in parallel to multiple sprites and the frame script (including beginSprite, endSprite and prepareFrame).

  • The new mouseWithin, mouseEnter, and mouseLeave events make it much easier to handler rollovers on a per-sprite ...

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.