Using Director > Parent Scripts > Using actorList

 

Using actorList

Lingo can set up a special list of child objects (or any other objects) that receives its own message each time the playback head 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.

The message is the stepFrame message that is sent only when the playback head enters a frame or the updateStage command is used. See on stepFrame.

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 playback head enters a new frame or the updateStage command updates the Stage.

Some possible uses of the 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 playback head 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 the actorList respond to stepFrame messages more efficiently than to an enterFrame message or to a custom message sent after an updateStage command.

To add an object to actorList, use the following statement:

add the actorList, theObject 

The object's on stepFrame handler in its parent or ancestor script will then run automatically each time the playback head advances. The object will be passed as the first argument (that is, the me argument) to the on stepFrame handler.

Director doesn't clear the contents of actorList when branching to another movie, which can cause unpredictable behavior in the new movie. If you don't want child objects in the current movie to be carried over into the new movie, insert a statement that clears actorList in the on prepareMovie handler of the new movie.

To clear child objects from actorList:

Set actorList to [ ], which is an empty list.

For more information, see actorList and on stepFrame..