User Guide

424
When new() is used to create a timeout object, the timeoutPeriod sets the number of milliseconds
between timeout events sent by the timeout object. The
#timeoutHandler is a symbol that
identifies the handler that will be called when each timeout event occurs. The targetObject
identifies the name of the child object that contains the
#timeoutHandler. If no targetObject
is given, the
#timeoutHandler is assumed to be in a movie script.
When a timeout object is created, it enables its
targetObject to receive the system events
prepareMovie, startMovie, stopMovie, prepareFrame, and exitFrame. To take advantage of
this, the targetObject must contain handlers for these events. The events do not need to be
passed in order for the rest of the movie to have access to them.
To see an example of
new() used in a completed movie, see the Parent Scripts, and Read and
Write Text movies in the Learning/Lingo Examples folder inside the Director application folder.
Examples
To create a new bitmap cast member in the first available slot, you use this syntax:
set newMember = new(#bitmap)
After the line has been executed, newMember will contain the member reference to the cast
member just created:
put newMember
-- (member 1 of castLib 1)
The following startMovie script creates a new Flash cast member using the new command, sets the
newly created cast members
linked property so that the cast members assets are stored in an
external file, and then sets the cast members
pathName property to the location of a Flash movie
on the World Wide Web:
on startMovie
flashCastMember = new(#flash)
member(flashCastMember).pathName = "http://www.someURL.com/myFlash.swf"
end
When the movie starts, this handler creates a new animated color cursor cast member and stores
its cast member number in a variable called
customCursor. This variable is used to set the
castMemberList property of the newly created cursor and to switch to the new cursor.
on startmovie
customCursor = new(#cursor)
member(customCursor).castMemberList = [member 1, member 2, member 3]
cursor (member(customCursor))
end
These statements from a parent script include the on new handler to create a child object. The
parent script is a script cast member named Bird, which contains these handlers.
on new me, nameForBird
return me
end
on fly me
put "I am flying"
end