Lingo: A Quickie Overview
Lingo is often referred to as a scripting language, which means it's a simple programming language. Its purpose is to allow the author (you!) to make a Director movie do more & be smarter.
Without Lingo, just about all you can do in Director is create animation and then play it. With Lingo you can make a movie that can respond to user input (such as a mouse click) and make decisions (using logic). For example, you can create an animation and then use Lingo to make VCR-type buttons that allow your user to control their experience with your movie.
A language like Lingo is said to be event driven. That is, the action in the movie doesn't just happen but, rather, is "driven" by "events." For example: the user clicks on a button (the event), the movie responds by playing a section of animation in the score (the action). Cause and effect; event leads to action. So when it's time to create a script, you'll need to answer two questions:
(Tip: You're going to have to answer the second question first!)
How do I use Lingo?
You use Lingo by creating scripts (which you write in the Lingo language, of course) and placing these scripts where you need them. A script can be assigned to a frame in the score, or attached directly to a sprite. Each script will be a unique cast member. In this class, we'll learn about two types of scripts: frame scripts and behaviors.
So how do I create a script?
You can let the Behavior Inspector write your script for you, or you can open the script window and write your own. We'll learn how to do both.
Some examples of events that Director can recognize:
mouseDown - user clicks down
mouseUp - user releases mouse button
mouseEnter - user rolls mouse over sprite
mouseLeave - moves mouse away from sprite
keyDown - user presses keyboard key
exitFrame - playback head exits frame
Some actions you might choose to put in your movie:
Here's the guts of a simple behavior you might use on a button that plays an animation (sends the playback head to a marker called "MyAnimation") in your movie:
on mouseUp
go to "MyAnimation"
end
This little bit of code is called an event handler because, well, it "handles" the mouseUp "event." An event handler always:
*You may see the word "me" following the event, e.g. "on mouseUp me". You can ignore it, or even delete it - it has no meaning in this class, it's for advance lingoists.
In Director, you can write the script yourself or you can use the Behavior Inspector to build it!