40
Chapter 2: Director Scripting Essentials
The following statements illustrate defining the linear list
workerList
that contains one value,
Heather
, and then adds
Carlos
as the second value in the list.
-- Lingo syntax
workerList = ["Heather"] -- define a linear list
workerList[2] = "Carlos" -- set the second value using the equal operator
workerList.setAt(2, "Carlos") -- set the second value using setAt()
// JavaScript syntax
var workerList = list("Heather"); // define a linear list
workerList[2] = "Carlos"; // set the second value using the equal operator
workerList.setAt(2, "Carlos"); // set the second value using setAt()
To retrieve a value in a linear list:
•
Use the list variable followed by the number that indicates the value’s position in the list. Place
square brackets around the number.
•
Use the
getAt()
method.
The following statements create the linear list
workerList
, and then assign the second value in
the list to the variable
name2
.
-- Lingo syntax
workerList = ["Bruno", "Heather", "Carlos"] -- define a linear list
name2 = workerList[2] -- use bracketed access to retrieve "Heather"
name2 = workerList.getAt(2) -- use getAt() to retrieve "Heather"
// JavaScript syntax
var workerList = list("Bruno", "Heather", "Carlos");
var name2 = workerList[2] // use bracketed access to retrieve "Heather"
var name2 = workerList.getAt(2) // use getAt() to retrieve "Heather"
To set a value in a property list, do one of the following:
•
Use the equals (=) operator.
•
In Lingo only, use the
setaProp()
method.
•
Use dot syntax.
The following Lingo statement uses the equals operator to make
sushi
the new value associated
with the property
Bruno
.
-- Lingo syntax
foodList = [:] -- define an empty property list
foodList[#Bruno] = "sushi" -- associate sushi with Bruno
The following Lingo statement uses
setaprop()
to make
sushi
the new value associated with
the property
Bruno
.
-- Lingo syntax
foodList = [:] -- define an empty property list
foodList.setaProp(#Bruno, "sushi") -- use setaProp()
// JavaScript syntax
foodList = propList() -- define an empty property list
foodList.setaProp("Bruno", "sushi") -- use setaProp()
The following statements use dot syntax to set the value associated with
Bruno
from
sushi
to
teriyaki
.
Summary of Contents for DIRECTOR MX 2004
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...