Understanding Basic Lingo (Handlers, Syntax, Handler Hierarchy and Navigation)

The "handler" is the basic building block of lingo scripting. Lingo scripts begin with a handler that tells Director when to apply the script. Handlers are triggered by Director events, such as when the mouse button is pushed or the playback head enters or exits a frame. Such events create a "message" in Director. Handlers always start with the word "on" followed by the name of the message to which they should respond.

Lingo Syntax

on mouseDown

When this happens
     beep do this command
     alert "Someone pushed a mouse button" and then do this command
end and then stop

Common handlers include:

on enterFrame Play back head enters current frame
on exitFrame Playback head exits current frame
on mouseDown Mouse button is pressed
on mouseUp Mouse button is released
on mouseEnter Pointer enters a sprite region
on mouseLeave Pointer exits a sprite region
on mouseWithin Pointer remains within a sprite region
on keyDown A key is pressed
on keyUp A key is released
on startMovie The movie starts playing
on stopMoviie The movie stops playing
on idle Nothing is happening
on prepareFrame Playhead is about to enter a frame
on beginSprite Playback head enters a frame with a new sprite
on endSprite Playback head leaves a sprite

Handler Hiearchy

Lingo scripting can be applied to sprites, cast members, frames, and movies. Thus there are four basic lingo scripts: sprite scripts (also called behavior scripts), cast scripts, frame scripts (or a behavior in the Frame Script channel), and movie scripts -- and they are applied in that hierarchical order.

Lingo and Navigation

One of the most common uses of lingo is to tell Director how to navigate the timeline... ie where to go when certain things happen (such as a button being pushed). The most common lingo navigation command is "go".

Common Go commands

go to the frame Begins the same frame over again (this is the most common script in Lingo)

go to frame x

goes to frame number x
go to the frame + x ; go to the frame - x goes ahead (or back) x number of frames
go to "yourmarker" goes to the frame labeled with "yourmarker"
go next goes to the next frame labeled with a marker
go previous goes to the previous frame labeled with a marker
go loop goes to the currently labeled marker
go marker(x) ; go marker(-x) goes forward/back x number of labeled markers
go to movie "yournextmovie.dir" goes to a new director movie called "yournextmovie.dir"
go to frame "yourmarker" of movie "yournextmovie.dir" goes to the frame labeled with "yourmarker" of a new director movie called "yournextmovie.dir"

Handlers and Go Commands In Action

Much basic programming and interactivity can be accomplished simply by applying the appropriate "Go" command to the appropriate "On" handler, such as in the examples below:

on exitFrame

When the playback is exiting the current frame
     go to the frame Start playing the current frame again
end And that's it

on mouseUp

When the user releases the mouse button
     go to frame 20 Start playing from frame 20
end And that's it