608
Chapter 13: Operators
Each entry in a linear list is a single value that has no other property associated with it. Each entry
in a property list consists of a property and a value. The property appears before the value and is
separated from the value by a colon. You cannot store a property in a linear list. When using
strings as entries in a list, enclose the string in quotation marks.
For example, [6, 3, 8] is a linear list. The numbers have no properties associated with them.
However, [#gears:6, #balls:3, #ramps:8] is a property list. Each number has a property—in this
case, a type of machinery—associated with it. This property list could be useful for tracking the
number of each type of machinery currently on the Stage in a mechanical simulation. Properties
can appear more than once in a property list.
Lists can be sorted in alphanumeric order. A sorted linear list is ordered by the values in the list. A
sorted property list is ordered by the properties in the list. You sort a list by using the appropriate
command for a linear list or property list.
•
In linear lists, symbols and strings are case sensitive.
•
In property lists, symbols aren’t case-sensitive, but strings are case-sensitive.
A linear list or property list can contain no values at all. An empty list consists of two square
brackets ([ ]). To create or clear a linear list, set the list to
[ ]
. To create or clear a property list, set
the list to [:].
You can modify, test, or read items in a list.
Lingo treats an instance of a list as a reference to the list. This means each instance is the same
piece of data, and changing it will change the original. Use the
duplicate
command to create
copies of lists.
Lists are automatically disposed when they are no longer referred to by any variable. When a list is
held within a global variable, it persists from movie to movie.
You can initialize a list in the
on prepareMovie
handler or write the list as a field cast member,
assign the list to a variable, and then handle the list by handling the variable.
Not all PC keyboards have square brackets. If square brackets aren’t available, use the
list
function to create a linear list.
For a property list, create the list pieces as a string before converting them into a useful list.
myListString = numToChar(91) & ":" & numToChar(93)
put myListString
-- "[:]"
myList = myListString.value
put myList
-- [:]
put myList.listP
-- 1
myList[#name] = "Brynn"
put myList
-- [#name: "Brynn"]
Example
This statement defines a list by making the
machinery
variable equal to the list:
-- Lingo syntax
machinery = [#gears:6, #balls:3, #ramps:8]
// JavaScript syntax
var machinery = propList("gears",6, "balls",3, "ramps",8);
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...