Lingo basics

-- exercise I, March 15, 2000 --
 

   
   
Contents  

I. Controlling navigation.
II. Text input.
III. Animation by cast member shifting.
IV. Rubberbanding.
V. Autonomous time-based behavior.

   
   
       
   


The Alien Relations Primer. Click labels to view illustrations of everyday alien social interaction.

   
   
Introduction  

The aim of this module is to learn how to control navigation in the Director score using simple Lingo constructs. You can use this technique for simple scene-based multimedia presentations, for interactive film, etc.

   
   
Structure  

The Alien Relations Primer has five parts. The first part is the static start screen. When the user selects on of the four illustrations (argument, love, hate and bletznik), a short score-based animation is played.

We structure the score in a similar way. The start frame contains a frame script which keeps the playback head in the frame by using a loop. Each of the animation sequences gets its own section in the score. We might use markers in the score to label the first frames of the five sections. For instance, they could be called start, argument, love, hate and bletznik.

In order to make playback jump to the right animation when the user clicks a label in the start frame, we give each of the label sprites a sprite script that sends the playback head to the first frame of the corresponding section. The last frame of the section needs to contain a frame script that sends the playback head back to the start frame. This frame script can be the same for all four animations.

   
   
Relevant Lingo  

on exitFrame. A frame script handler that is called when the playback head is ready to leave the frame. Useful for creating the loop in the start frame:

on exitFrame
  go to the frame
end exitFrame

You will also need on exitFrame handlers for the frame script in the last frame of each animation sequence.

To send the playback head to a specified frame, use go to frame <marker label or number>. For example, you can write go to frame "love" or go to frame 23.

User selection of a scene to play can be captured with a handler on each of the four label sprites (argument, love, hate, bletznik). The most common way to capture a mouse click is to use the on mouseUp handler:

on mouseUp
  go to frame "love"
end mouseUp

The example above would be the handler for the love label, for instance.

   
   
Optional work  

You might have noticed the rollover feedback on the selectable labels in the Alien Relations Primer above. As the user moves the cursor over one of the labels, a rectangle appears. When the cursor leaves the label, the rectangle disappears again.

If you want to build a similar effect, a simple way is to draw each of the four highlights as a separate sprite in the score. When the movie starts playing, you make them all invisible. You give each of the selectable labels a couple of sprite handlers that make the corresponding rectangle visible when the cursor is over the sprite, and invisible again when the cursor leaves the sprite.

Here are the Lingo primitives you need.

on startMovie. A handler that you put in a movie script. It is called when the movie starts playing. Note: It might be tricky to create a movie script. A safe way is to open the Script window from the Window menu, click the plus sign to create a new script, click the info ("i") icon and set the type to Movie in the Type menu of the Cast Member Properties dialog.

on mouseEnter and on mouseLeave. Handlers that you put in a sprite or cast member script. Called when the cursor enters or leaves the sprite on stage.

the visible of sprite. A property that has the values TRUE and FALSE. Can be tested and set in Lingo code. A sprite handler for one of the user selectable labels might look like this (provided that the rectangle we want to pop up is in sprite channel 14).

on mouseEnter
  set the visible of sprite 14 to TRUE
end mouseEnter

on mouseLeave
  set the visible of sprite 14 to FALSE
send mouseLeave