MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING Reference page 22

Director scripting reference
Table of Contents

Advertisement

To assign a value to a variable:
Use the equals (
For example, the following statement assigns a URL to the variable
// JavaScript syntax
var placesToGo = "http://www.macromedia.com";
Variables can also hold the results of mathematical operations. For example, the following
statement adds the result of an addition operation to the variable
-- Lingo syntax
mySum = 5 + 5 -- this sets mySum equal to 10
As another example, the following statement returns the cast member assigned to sprite 2 by
retrieving the value of the sprite's
-- Lingo syntax
textMember = sprite(2).member
It is good practice to use variable names that indicate what the variable is used for. This makes
your scripts easier to read. For example, the variable
sum of numbers.
To test the values of properties or variables:
Use the
put()
Watcher window; (
both Lingo and JavaScript syntax).
For example, the following statement displays the value assigned to the variable
Message window.
-- Lingo syntax
myNumber = 20 * 7
put(myNumber) -- displays 140 in the Message window
// JavaScript syntax
var myNumber = 20 * 7;
trace(myNumber) // displays 140 in the Message window
Using global variables
Global variables can be shared among handlers, scripts, or movies. A global variable exists and
retains its value as long as Director is running or until you call the
In Macromedia Shockwave Player, global variables persist among movies displayed by the
goToNetMovie()
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 is good practice to start the names of all global variables with a lowercase g. This helps identify
which variables are global when you examine your code.
Director provides a way to display all current global variables and their current values and to clear
the values of all global variables.
22
Chapter 2: Director Scripting Essentials
) operator.
=
member
or the
functions in the Message window or check the values in the
trace()
and
put()
trace()
method, but not among those displayed by the
property and places it into the variable
indicates that the variable contains a
mySum
provide identical functionality and are available to
:
placesToGo
:
mySum
textMember
myNumber
method.
clearGlobals()
method.
goToNetPage()
.
in the

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Director mx 2004

Table of Contents