CLASS 3• TECHNICAL OBJECTIVES

Skill 3.1) Introduction to using global variables in Director

Global variables can be shared among handlers and movies. A global variable exists and retains its value as long as Director is running or until you issue the clearGlobals command.

Every handler that declares a variable as global can use the variable's current value. If the handler changes the variable's value, the new value is available to every other handler that treats the variable as global. It's good practice to start the names of all global variables with a lowercase g. This helps identify which variables are global when you examine Lingo code. Because you usually want global variables to be available throughout a movie, it is good practice to declare global variables in an "on startMovie" handler. This ensures that the global variables are available from the very start of the movie.

Syntax: clearGlobals

Description Command; sets all global variables to VOID.

Syntax: showGlobals

Description Command; displays all global variables in the Message window.

Global Variables skills check:

Skill 3.2: Using color()

color()
Returns: rgb(integer 1-255, integer 1-255, integer 1-255)
The color function (used like a property in the examples below) returns a rgb value.

Example
This statement changes the color of the fourth through the seventh characters of text member myQuotes: member("myQuotes").char[4..7].color = rgb(200, 150, 75)

Example
This Lingo sets the color of sprite 6 to a pure green RGB value:
sprite(6).color = rgb(0, 255, 0)

Color skills check:

Other Lingo:

getPixel()

grabcolor=member("grabbedframe").image.getPixel(the mouseH, the mouseV)
--this statement sets a variable called "grabcolor" to the rgb value that the mouse is over

numToChar()
Syntax: numToChar(integerExpression)
Description of function; displays a string containing the single character whose ASCII number is the value of integerExpression. This function is useful for interpreting data from outside sources that are presented as numbers rather than as characters.
ASCII values up to 127 are standard on all computers. Values of 128 or greater refer to different characters on different computers.