Multimedia Programming: Scripting (Lingo)
Multimedia Programming: Scripting (Lingo)
Multimedia Programming: Scripting (Lingo)
Director Basics
Director movies are interactive multimedia pieces that can include animation, sound, text, digital video, and many other types of media. A movie can be as small and simple as an animated logo or as complex as an online chat room or game.
The Stage is the visible portion of a movie. Use the Stage to determine
where media appears.
the Control Panel , which controls how the movie plays back
Movie properties specify properties that affect the entire movie, such as:
how colors are defined the size and location of the Stage the number of channels in the Score copyright information font mapping
Channels
Channels are the rows in the Score that contain sprites for controlling media. Sprite channels are numbered and contain the sprites that control all the visible media in the movie. Special effects channels at the top of Score contain behaviors as well as controls for the tempo, palettes, transitions, and sounds.
Frames
Frames are represented by the numbers listed horizontally in the sprite and special effects channels. A frame is a single step in the movie.
Setting the number of frames displayed per second sets the movies playback speed.
Sprites
Sprites are objects that control when, where, and how media appears in a movie. The media assigned to sprites are cast members. Creating a Director movie consists of defining: where sprites appear on the Stage when they appear in the movie how they behave what their properties are.
Cast members
Cast members are the media that make up a movie. They can include:
bitmap images text vector shapes sounds Flash movies digital videos
Markers
Markers identify fixed locations at a particular frame in a movie. Using Lingo or draggable behaviors, you can instantly move the playback head to any marker frame. This is useful when :
jumping to new scenes from a menu or looping while cast members download from the web. Markers are also useful while authoring to advance quickly to the next scene.
Use the Markers window to write comments associated with markers you set in the Score and to move the playback head to a particular marker.
To create a marker:
Click the markers channel to create a marker. A text insertion point appears to the right of the marker. Type a short name for the marker.
To delete a marker:
Drag the marker up or down and out of the markers channel.
Press the 4 and 6 keys on the numeric keypad to cycle backward and forward
through markers. Choose the name of a marker from the Markers menu.
Editing Frames
To move or delete all the contents of a range of frames:
Double-click and drag in the frame channel to select frames. Choose Edit > Cut or Edit > Copy, or press Delete. If you cut or delete the selected frames, Director removes the frames and closes up the empty space.
To paste copied frames, select any frame and choose Edit > Paste.
The function marker() with the number of markers used as the parameter refers to the marker thats a specific number of markers before or after the current frame. For example, marker(-1) gives the previous marker. If the frame is marked, marker(0) gives the current frame; if not, marker(0) gives the name of the previous marker. The word movie followed by the movie name refers to the beginning of another movie. For example, movie "Navigation" refers to the beginning of the Navigation movie. The word frame plus a frame identifier, the word of, the word movie, and the movie name refers to a specific frame in another movie; for example, frame 15 of movie "Navigation" refers to frame 15 of the Navigation movie.
Lingo Scripting
When does Lingo run?
When an event occurs, Director generates a message that describes the event. Handlers contain groups of Lingo statements that run when a specific event occurs in a movie. Each handler begins with the word on followed by the message that the handler is set to respond to. The last line of the handler is the word End.
Lingo supports a variety of data types: references to sprites and cast members, (Boolean) values: TRUE and FALSE , strings, constants, integers, floating-point numbers.
Scripts can use variables to store, update, and retrieve values as the movie plays.
Use the equals operator (=) or the set command to assign values to variables. Use if...then, case, and repeat loop structures to set up statements so that they run when specific conditions exist. Director always executes Lingo statements in a handler starting with the first statement and continuing in order until it reaches the final statement
Dot Syntax
Use dot syntax to express the properties or functions related to an object or to specify a chunk within a text object. Dot syntax expression: name of the object, followed by a period (dot), and then the property, function, or chunk that you want to specify.
For example
The property : the loc sprite property indicates a sprites horizontal and vertical position on the Stage. The expression : sprite(15).loc refers to the loc property of sprite 15. The expression : member("Hot Button").number refers to the cast member number of the Hot Button cast member. Expressing a function : textSpriteObject.pointInHyperlink chunks of text : member("News Items").paragraph(1)
Parentheses
Functions that return values require parentheses. Use parentheses after the keywords sprite or member to identify the objects identifier:
Character spaces
Words within expressions and statements are separated by spaces. Lingo ignores extra spaces. Uppercase and lowercase letters Lingo is not case sensitive
Comments
Comments in scripts are preceded by double hyphens (--). You can place a comment on its own line or after any statement.
Literal Values
A literal value is any part of a statement or expression that is to be used exactly as it is, rather than as a variable or a Lingo element.
Literal values character strings, integers, decimal numbers, cast member names, cast member numbers, symbols, and constants.
o You can convert a decimal number to an integer by using the integer() function. For example, set theNumber = integer(3.9)
decimal number is what Lingo refers to as a floating-point number. The floatPrecision property controls the number of decimal places used to display these numbers. o You can convert an integer or string to a decimal number by using the float() function. set theNumber = float(3)
member("Jason_Jones-Hughes") member(50) member "Jason_Jones-Hughes" member 50 To specify a cast when using member without parentheses, include the term of castLib followed by the casts name or number.
For example, the following statements refer to cast member 50, which is named Jason Jones-Hughes, in castLib 4, which is named Wales Player: member(50, 4) member 50 of castLib 4 member("Jason_Jones-Hughes", 4) member "Jason_Jones-Hughes" of castLib 4 member(50, "Wales_Player") member 50 of castLib "Wales_Player" member("Jason_Jones-Hughes", "Wales_Player") member "Jason_Jones-Hughes" of castLib "Wales_Player"
symbol is a string or other value that begins with the pound sign (#). Symbols are user-defined constants. symbols can usually be performed very quickly, providing more efficient code. For example, userLevel = #novice userLevel = "novice Convert a string to a symbol by using the symbol() function. Convert a symbol back to a string by using the string() function. constant is a named value whose content never changes. For example, TRUE, VOID, and EMPTY are constants because their values are always the same. For example, to test whether the user is pressing the Enter key, use the following statement: if the key = ENTER then beep
Lingo operators
Arithmetic operators (such as +, -, /, and *) Comparison operators (for example, +, >, and >=), which compare two
arguments
Logical operators (not, and, or), which combine simple conditions into compound ones String operators (& and &&), which join strings of characters
Lingo Lists
Lists are basically a set of elements separated by commas. Lingo encloses the set of values in square brackets. A simple example of a list is a list of numbers such as [1, 4, 2]. Lingo can create, retrieve, add to, reorder, sort, or substitute a lists contents.
When the movie first starts, events occur in the following order:
prepareMovie. beginSprite. prepareFrame. startMovie. This event occurs in the first frame that plays.