User Guide
Writing scripts in the Script window 79
Performing common tasks
The following are ways to perform common tasks for creating, attaching, and opening scripts.
To create a frame behavior (script attached to a frame):
• Double-click the behavior channel in the frame to which you want to attach the behavior.
When you create a new behavior, the behavior receives the cast library number of the first
available location in the current Cast window.
When you create a new frame behavior, the Script window opens and already contains the Lingo
on exitFrame handler The first line contains on exitFrame, followed by a line with a blinking
insertion point, and then a line with the word
end. This makes it easy for you to quickly attach a
common Lingo behavior to the frame. To make this handler work with JavaScript syntax, replace
on exitFrame with function exitFrame() {, and replace end with }.
One of the most common frame behaviors is one that keeps the playhead looping in a single
frame. This can be useful when you want your movie to keep playing in a single frame while
waiting for the user to click a button or for a digital video or sound to finish playing.
To keep the playhead in a single frame:
• In a frame behavior, type the following statement on the line after the on exitFrame (Lingo)
or
function exitFrame() (JavaScript syntax) statement:
-- Lingo syntax
_movie.go(_movie.frame)
// JavaScript syntax
_movie.go(_movie.frame);
The Movie object’s frame property refers to the frame currently occupied by the playhead. This
statement essentially tells the playhead to "go back to the frame you are currently in."
Behavior channels