Free technical help for digital creators - music, video, art, photography, graphic & web design

Basics of Director Lingo by Matt Ottewill

What is Lingo?

Lingo is Director's programming, or scripting, language. It is mature and powerful and an essential part of creating in-depth interactivity.

Types of Lingo scripts

Lingo scripts can exist in many locations throughout Director ...

  • Sprite scripts (Behaviours) are attached to sprites or groups of sprites in the score.

  • Cast member scripts are attached to individual cast members

  • Frame scripts (Behaviours) are attached to cells in the scores Scripting/Behaviours channel

  • Movie scripts are not attached to anything they are simply written and appear in the cast

Object hierarchy

In Lingo scripts are called Objects. When an event occurs a message is sent through these objects in a specific order ...

  1. Scripts attached to the sprite in question eg the button that was clicked.

  2. Cast member of the sprite in question.

  3. Scripts attached to the current frame.

  4. Movie scripts.

Lingo Elements

Handlers

Start with "on" and end with "end". There are 2 types:

  1. Event handlers - eg "on mouseUp"

  2. Custom handlers - eg "on fred". These handlers are triggered by "calls" rather than events.

download iconSound control 1 tutorial movie (.dir)

Commands

A Command is an instruction.

eg "go"
eg "delete"
eg "do"
eg "beep"

Functions

A Function gives a result.

eg The "clickOn" function returns the value (or number) of the sprite which has been clicked on.
eg The "date" is a function which returns the current date.

download icon ClickOn function tutorial movie (.dir)

Properties

A Property is a specific value attached to an item. Properties can be changed interactively or over time. Property names are always preceded by "the"

eg the stagecolor

eg the locH (horizontal location)

download icon Interaction 1 tutorial movie (.dir)

Operators

Operators are mathematical expressions.

eg "+"
eg "x"

Keywords

Keywords complete the syntax of a script.

eg "the"
eg "to"
eg "repeat"

Variables

A variable is a "container" (bit of RAM) that may contain either -

  • Expressions

  • Strings (text). Any set of characters enclosed in quotations (") is considered a string.

  • Values (numbers)

  • Booleans (eg true or false, on or of)

  • Integers (whole numbers)

  • etc

There are 4 types of variables:

  1. Local variables A local variables only exist inside the handler that initialised it (by naming therefore creating them). Local variables cannot be "interrogated" by other variables.

  2. Global variables A global variable may be interrogated at any time by any handler.

  3. Arrays (called Lists in Lingo) There are 2 types of lists. 1) Property lists. 2) Lists

  4. Constant A variable that once initialised with a value doesn't change, such as - the best score in a game or a players name.


download icon Global variables / field text feedback tutorial movie (.dir)

download icon Sound control 1 tutorial movie (.dir)

Need help downloading these files?

Control statements

Control statements always start with "if". For example ...

if the member of sprite the CurrentSpriteNum = "Button up" then
set the member of sprite the currectSpriteNum = "Button down"
else
nothing
end if

download icon Blending disc tutorial movie (.dir)

download icon Spinning disc tutorial movie (.dir)

download icon Interaction 1 tutorial movie (.dir)

Need help downloading these files?

Repeat loops

Repeat loops start with "repeat" and finish with "end". The statements between them will repeat until a condition is met. There are several types of Repeat Loop such as "repeat while" and "repeat with". The following is a script example:

on startMovie
startTimer
repeat while the timer < 200
beep
end repeat
end

download icon Repeat while loop/Timer movie (.dir)

download icon Repeat with loop/Timer movie (.dir)

Need help downloading these files?

More on repeat loops here

Field text

Ai addition to standard "display" text fields, Lingo uses "live" field text elements which allow user entry and can be used to display results of calculations or other processes.

download icon Calculator tutorial movie (.dir)

download icon Simple quiz tutorial movie (.dir)

download icon Global variables / field text feedback tutorial movie (.dir)

Need help downloading these files?

MIAWs (Movies In A Window)

A MIAW is an object in RAM. It's a movie launched into its own window by another movie which is already running in RAM. Click here for more.