80
Chapter 3: Writing Scripts in Director
To create a sprite behavior (script attached to a sprite):
•
In the Score or on the Stage, select the sprite that you’re attaching the behavior to. Then select
Window > Behavior Inspector and select New Behavior from the Behavior pop-up menu.
When you create a new sprite behavior, the Script window opens and already contains the Lingo
on mouseUp
handler. The first line contains the line
on mouseUp
, 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 behavior to the sprite. To make this handler work with JavaScript syntax,
replace
on mouseUp
with
function mouseUp() {
, and replace
end
with
}
.
To open a behavior for editing:
1
Double-click the behavior in the Cast window.
The Behavior inspector opens.
2
Click the Script Window icon in the Behavior inspector.
The Script window displays the behavior.
Alternatively, you can open the Script window and cycle through the scripts until you reach
the behavior.
To remove a behavior from a Score location:
•
Select the location and then delete the script from the list displayed in the Property inspector
(Behavior tab).
To attach existing behaviors to sprites or frames, do one of the following:
•
Drag a behavior from a cast to a sprite or frame in the Score or (for sprites) to a sprite on
the Stage.
•
In the score, select the sprites or frames that you’re attaching the behavior to. Then
select Window > Behavior Inspector and select the existing behavior from the Behavior
pop-up menu.
To create a movie script (script attached to a movie), do one of the following:
•
If the current script in the Script window is a movie script, click the New Script button in the
Script window. (Clicking the New Script button always creates a script of the same type as the
current script.)
•
If the current script in the Script window is not a movie script, click the New Script button
and then change the new script’s type with the Script Type pop-up menu in the Script tab of
the Property inspector.
•
If no sprites or scripts are selected in the cast, Score, or Stage, then open a new Script window;
this creates a new movie script by default.
To open a movie script or parent script for editing:
•
Double-click the script in the Cast window.
To change a script’s type:
1
Select the script in the Cast window or open it in the Script window.
2
Click the Script tab of the Property inspector and select a script type from the Script Type
pop-up menu.
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...