In Director it is possible to manually program almost anything Director can do. The scripting language used in Director is Lingo. Lingo is a basic scripting language and is easy to master.
First thing to know is that there are different types of Lingo-scripts:
The first kind of script, the movie script can be called to the screen pressing CRTL+SHIFT+U, or select
from the menu.(!) You will see a completely empty text screen and it is up to you to fill it!
handlers
In Lingo you can define what are called
'handlers', these are actually functions and are similar like for example Javascript. An example of a Movie-script with
two handlers is:
global variables
This example is actually the same as the example before except thhat the text is now stored in two global
variables.
Variables in Lingo do not have a type specification, the variable gets it's type when it is first set or when it
is reset. Too assign a value to a variable the following notations can be used: 'set [variable_name] to [some_string_or_other_value]'
or
'set [var] = [some]' for those of you who dislike programming with a lot of words.
When a variable is reset the type is also
reset, so the following code will give an error:
Lingo also has a lot of system
variables which can be used at any time. System variables often consist of the word 'the' followed by the variable. this can
be confusing when debugging if you forget the word 'the' since Lingo will create a new local variable. Some System variables
are 'the mouseV' (vertical position of the mouse-pointer), 'the mouseH' (horizontal position of the mouse-pointer),
'the shiftDown' (boolean presenting wheter the 'shift' key is pressed or not), 'the key' (the last key pressed) etcà
One
very important system-variable is 'the frame' which denotes the current frame of the movie and is much used in frame-scripts.
In
addition to movie-scripts you can also use score-scripts. These are either frame-scripts, sprite-scripts or behaviors
(which are actually sprite or score-scripts but more on bahaviours later).
Frame-scripts are defined in the first line
of the upper-part of the score and can be accessed by double-clicking on a cell.
frame scripts
In
a frame-script code is programmed which will only be executed when the play-back-head of the movie is at the frame. Handlers
that can be used in a frame script are: 'on prepareFrame', 'on enterFrame', 'on exitFrame' and there effects are obvious.
or
In both examples the 'go to' command is
issued. This command expects a integer value which represent a frame (the first frame is number 1 and so on). In the first example
the go to commands goes to 'the frame' which is the frame the script is in so the play-back head enters the same frame again and
thus a loop is created!
In the second example the play-back head goes to the frame where the marker "the end" is defined.
A sprite
script is also a score-script. Sprite-scripts can be called from the menu at sprites or cast members.
sprite script
Sprites can have multiple scripts on them as long as there aren't more then one of each handler. Hanlders often
used in sprite scripts are: 'on beginSprite',
'on endSprite', 'on mouseOver', 'on mouseLeave', 'on mouseDown', 'on mouseUp'
etc.
sprite script
Sprite-scripts are often referred to as behaviors. In effect these scripts do not differ accept that
behaviors can be attached to multiple sprites without being copied. So if the behviour script changes the script on all sprites
with the behavior changes. In contradiction sprite-scripts are private too the sprite.
draft version 0.5 (12/3/2001)How does Lingo work?
Note:
A handler always begins with on and then follows the 'event'. In this example
two handlers are programmed, the things that must be done when the movie starts and the things that must be done when the movie
ends. A handler always closes with the word end.
Note:
Note:
In this example I have issued the command 'alert [string]' which
gives a popup-box with the string displayed in it (very useful for debugging your code!). Another way to debug your code is
too issue some 'put
Another
movie handler is 'on prepareMovie' which is executed before 'on startMovie' and is useful for setting starting-variables.
To create a variable that is accessible for more handlers, you must create a 'global' variable. You can define a global variable
anywhere outside any handler in which case it is accessible by all handlers in the same script and handlers in other scripts
that include the variable. Or you can define a global variable inside a script. In this case the variable is only accessible
for that handler and any other handler that also defines the variable.
Example:
global endText
alert endText
end
Note:
Example:
Example:
Note:
Note:
Note:
Reference:
Reference:
Reference:
[]
intro
windows
concepts
tools
howto
lingo
advanced
summary
resources
eliens@cs.vu.nl