Writing Scripts with Lingo
399
For example, the following statements have the same effect; each statement creates a linear list of
three names:
set workerList = ["Bruno", "Heather", "Carlos"]
set workerList = list("Bruno", "Heather", "Carlos")
To create an empty linear list:
•
Set the list to
[ ]
.
Creating property lists
The only way to create a property list is to use the list operator (
[ ]
). You cannot use the
list()
function to create a property list.
To create a property list:
•
Place the list elements within the list operator, and use commas to separate the elements.
Precede each property with the pound (#) sign, and separate each property from its value
with a colon.
For example, the following statements create two different property lists. Each list specifies the
Stage coordinates of a sprite.
sprite1Location = [#left:100, #top:150, #right:300, #bottom:350]
sprite2Location = [#left:400, #top:550, #right:500, #bottom:750]
To create an empty property list:
•
Set the list to
[:]
.
Setting and retrieving items in a list
Lingo lets you set and retrieve individual items in a list. The syntax differs for linear and
property lists.
To set a value in a linear list:
•
Use the equals (=) operator. (You can also use the
setAt
command introduced in earlier
versions of Director.)
For example, the statement
workerList[2] = "Tiffany"
makes Tiffany the new value for the
second item in the list workerList.
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. (You can also use the
getAt
or
getaProp
commands,
which were introduced in earlier versions of Director.)
For example, in the linear list
set workerList = ["Bruno ", "Heather ", "Carlos "]
,
the expression
workerList[2]
represents the second value in the list workerList. The value
is Heather.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...