- Hits: 6591
In this exercise you will learn how to use Lingo to move the playhead to control the flow of content in your movies.
The playhead is the red box and vertical line that appears in the Score window in Director to indicate which frame is currently being displayed. A timeline metaphor is a common model to use to visually understand temporal relationships of content in a variety of software applications. Fortunately, the Lingo required to control the playhead is very easy to learn and implement.
The Go Property of a Movie:
The '_movie.go' property of a movie controls where the playhead goes in a movie, and '_movie.go' always requires a parameter describing the destination frame or movie. The parameter can be a number, a string, or a mathematical expression that returns a number for the destination frame.
Perhaps the most common use for ' _movie.go' is to keep the playhead from going anywhere. This is essential if elements on a screen, such as buttons, or Lingo-driven animation are to be controlled by the user. Obviously, the frame having interactive elements for the user to activate has to be displayed long enough for the user to read or click its content. To keep the playhead in one place you can use the '_movie.frame' property, which always displays the current frame the playhead is rendering.
If we tell Director to move the playhead to the same frame over and over, the effect is that the currently rendered frame remains visible, until other events or messages explicitly move the playhead. The script to keep the playhead on the same frame over and over is placed in each frame where your want the "hold frame" effect. The code example below uses the 'exitFrame' message, which is a built-in message generated by Director, and processed just before the next frame is prepared for rendering. The 'exitFrame' message is sent at a rate that matches the current framerate of your movie. Typically, the framerate of a movie is set to 30 or 60 fps (frames per second), depending on how critical the screen refresh needs. When including the below script in your movie make sure to name it, so it's easy to locate in your Cast, and remember that this script can be re-used over and over from one base copy. A good convention to follow is to name the script "Hold Frame," but of course any descriptive name will do.
As a script in the Script Window, the above code would appear as shown below.
Note that the script has been given the name "Hold Frame" to make it easier to identify among other cast members. It is always a good practice to name all cast members, but remember to make sure each cast member has a unique name.
Below, is a screen image showing how the above script would be incorporated into the Scoreof a movie.
The playhead is on frame 10, and the "_movie.go(_movie.frame)" script is placed in the frame as a frame script. This script can be used any number of places in the movie where you want the playhead to remain on the same frame.
Note: There is an option to display a "Script Preview" in the Score window that is very useful. When this is activated you will see the first line or two of a selected sprite's script above the marker track in the Score. The Script Preview area can be clicked to immediately view the script being previewed. To activate Script Preview, Right+Click in the area near the marker track in the Score, and check the "Script Preview" option.
When constructing a movie it is often useful to color sprites in the Score that serve different functions. For example, sprites colored "green" in the image to the right, named "left nav" and "right nav" indicate navigation elements.
The "cluster" of sprites are also given a marker label (called "main" in this case) to facilitate Lingo-based navigation to this part of the movie.
The "hold frame" script is placed at the end of the sprite cluster, though it could be placed anywhere within the cluster wherever the "hold frame" effect is needed.
The empty frames between the sprite clusters are arbitrary. When using Lingo to control the flow from one place in your movie to another the "empty" space between frame clusters is irrelevant since the destination frame will be rendered instantly. In this way the timeline is just a reference for the layout of your movie. The flow of the movie will be controlled by Lingo events and user interaction.
Once your movie is arranged in this fashion it is only a matter of wiring up navigation sprites to allow the user to choose where they want to go next.
Below, are a variety of Lingo examples to control the playhead. After reviewing the examples you should try them in your own movies, until you feel comfortable with the variety of commands and how to implement them. The "_movie" object includes a property called "go" that tells the playhead where to move, by frame number, or by frame label (marker). A period "." is used to specify what "_movie" property is being accessed. Using the syntax, "_movie.go" with a specification of where the playhead is to go can move the playhead anywhere, including a frame in a separate Director movie.
Go to a frame by frame number:
Go to a frame by marker label name:
Jump ahead 10 frames:
Go to a frame as referenced by a variable:
Go to the next marker in the timeline:
Go to the previous marker in the timeline:
Go to the currently labeled frame:
Go forward or backward 2 labeled frames:
Go to any frame and return to the previous frame:
Go to the frame of a different movie:
A text file containing all of the _movie.go variations may be downloaded here.
The above handlers provide nearly all of the types of _movie.go command implementations you are likely to use. After reviewing the handlers and trying them in your own movies you should feel completely comfortable using them to control the flow of content. If any of the above handlers seem confusing, just try them out to see what they do. Fortunately, the _movie.go command in Lingo is among the easiest to master.