On Jun 9, 2004, at 4:07 AM, Roland Schroth wrote:
> It is important that I can have more than one movie script with
> preapareMovie and startMovie procedures.
Hi Roland,
If you *really* want to do this, use the following handlers in the first
movie script that is to have an "on prepareMovie()" handler:
on prepareMovie(thisScript) ------------------------------------------
-- ACTION: Executes custom code, then calls all on prepareMovie()
-- handlers in all movie scripts available to this movie.
-- NOTE: This technique of passing a movie event to other scripts
-- is highly unorthodox. There are better ways of
-- achieving the same effect.
-- The on prepareMovie() handlers in subsequent scripts will
-- receive a pointer to the movie script object as a
-- parameter. The presence of this parameter can be used to
-- check that this particular handler is not called twice.
--------------------------------------------------------------------
-- Do prepareMovie stuff in this first script
put #prepareMovie -- Replace with your own instructions
if not voidP(thisScript) then
-- If this handler received a parameter, then it the call can't
-- have come from the Director Player itself. Do not cascade
-- calls to other scripts in this case.
exit
end if
-- Pass the event to all other movie scripts
CascadeEvent(#prepareMovie, TRUE) -- ignore first script (this one)
end prepareMovie
on CascadeEvent(anEvent, ignoreFirstScript) --------------------------
-- INPUT: <anEvent> should be a symbol handler name
-- <ignoreFirstScript> should be TRUE if the call comes from
-- a handler with the same name as <anEvent>. If the call
-- comes from a handler with a different name, it can be
-- FALSE or VOID.
-- ACTION: Passes the event call to all other movie scripts which
have a handler for it.
--------------------------------------------------------------------
-- Check input
if not symbolP(anEvent) then
exit
end if
ignoreFirstScript = (ignoreFirstScript <> 0) -- convert to boolean
-- End of input check
-- Iterate through all casts...
tMaxCastLib = the number of castLibs
repeat with tCastNum = 1 to tMaxCastLib
-- ... and all members in each cast, looking for movie scripts
-- with an "on <anEvent>()" handler
tMaxMember = the number of members of castLib(tCastNum)
repeat with tMemberNum = 1 to tMaxMember
tMember = member(tMemberNum, tCastNum)
if tMember.type = #script then
if tMember.scriptType = #movie then
tScript = script(tMember)
if tScript.handler(anEvent) then
-- We've found a movie script with the handler
if ignoreFirstScript then
-- The first script with an "on <anEvent>()" handler
-- will be this one. Don't call it again.
ignoreFirstScript = FALSE -- Do call subsequent scripts.
else
-- We've found a second or subsequent movie script with
-- an "on <anEvent>()" handler.
call(anEvent, tScript)
end if
end if
end if
end if
end repeat
end repeat
end CascadeEvent
You would need an "on startMovie()" handler similar to the "on
prepareMovie()" handler above, where you would call...
CascadeEvent(#startMovie, TRUE)
Why would you want to do this?
Cheers,
James
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL
PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping
with programming Lingo. Thanks!]