Writing Scripts with Lingo
423
To remove an object from actorList:
•
Use the
delete
command to delete the item from the list. See
delete
in the Lingo Dictionary.
Using scriptInstanceList
You can use the
scriptInstanceList
property to dynamically add new behaviors to a sprite.
Normally,
scriptInstanceList
is the list of behavior instances created from the behavior
initializers defined in the Score. If you add child objects created from parent scripts to this list, the
child objects receive the messages sent to other behaviors.
For example, this statement adds a child object to the
scriptInstanceList
property of sprite 10:
add sprite(10).scriptInstanceList, new(script "rotation", 10)
This is a possible parent script that the statement refers to:
-- parent script "rotation"
property spriteNum
on new me, aSpriteNum
spriteNum = aSpriteNum
return me
end
on prepareFrame me
sprite(spriteNum).rotation = sprite(spriteNum).ro 1
end
When a child object is added to
scriptInstanceList
, you must initialize the child object’s
spriteNum
property. Typically you do this from a parameter passed in to the
on new
handler.
Note:
The
beginSprite
message is not sent to dynamically added child objects.
Using actorList
Lingo can set up a special list of child objects (or any other objects) that receives its own message
each time the playhead enters a frame or the
updateStage
command updates the Stage.
The special list is
actorList
, which contains only objects that have been explicitly added to the
list. See
actorList
in the Lingo Dictionary.
The message is the
stepFrame
message that is sent only when the playhead enters a frame or the
updateStage
command is used. See
on stepFrame
in the Lingo Dictionary.
Objects in
actorList
receive a
stepFrame
message instead of an
enterFrame
message at each
frame. If the objects have an
on stepFrame
handler available, the Lingo in the
on stepFrame
handler runs each time the playhead enters a new frame or the
updateStage
command
updates the Stage.
Some possible uses of
actorList
and
stepFrame
are to animate child objects that are used as
sprites or to update a counter that tracks the number of times the playhead enters a frame.
An
on enterFrame
handler could achieve the same results, but the
actorList
property and
on
stepFrame
handler are optimized for performance in Director. Objects in
actorList
respond
more efficiently to
stepFrame
messages than to
enterFrame
messages or custom messages sent
after an
updateStage
command.
To add an object to the actorList:
•
Use the statement
add the actorList
,
theObject
.
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...