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

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 ...

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