This behavior will only work with filmloop cast members. Just drop it onto your filmloop sprite and adjust the settings for how many loops, the delay between loops and the loopback frame. Read the behavior description for more details.
on beginsprite me
set filmloopMem = the member of sprite spritenum
if the type of member filmloopMem <> #filmloop then
put "Filmloop control behavior attached to non filmloop sprite in channel"&&spritenum&", frame"&&the frame
end if
tell sprite spritenum
filmloopframes = the lastFrame
end tell
set counter = 1
set loopcount = 1
if loopTimes = 0 and framePause = 0 and loopBackTo <= 1 then
setFilmloopProp me, #loop, true
set state = #playingIndefinitely
else
set state = #playing
end if
if framePause <> 0 or loopBackTo > 1 then
setFilmloopProp me, #loop, false
end if
end
on getFilmloopStats me
tell sprite spritenum
fc = the lastFrame
cc = the lastChannel
f = the frame
end tell
return [#frames:fc, #channels:cc, #currentFrame:f]
end
--this is what makes it possible to change filmloop member properties--
on updateLoop me
set the media of member filmloopMem = the media of member filmloopMem
end
--triggers filmloop, resetting all counters
on triggerLoop me
tell sprite spritenum to go 1
set loopcount = 1
if loopTimes = 0 and framePause = 0 and loopBackTo <= 1 then
setFilmloopProp me, #loop, true
set state = #playingIndefinitely
else
set state = #playing
end if
end
on exitframe me
if the type of member filmloopMem <> #filmloop then return
tell sprite spritenum
flFrame = the frame
end tell
case state of
#idle, #playingIndefinitely:
return
#playing:
if flFrame >= filmloopframes then --we have finished a loop--
if (loopcount < loopTimes) or (loopTimes < 1) then
set loopcount = loopcount + 1
if framePause < 1 then
tell sprite spritenum to go to loopBackTo
else --setup delay--
set state = #waiting
set counter = 1
return
end if
else
setFilmloopProp me, #loop, false
set state = #idle
end if
end if
#waiting:
if counter < framePause then
set counter = counter + 1
else
set state = #playing
tell sprite spritenum to go to loopBackTo
end if
end case
end
on setFilmloopProp me, prop, val
if the type of member filmloopMem <> #filmloop then
put "Filmloop control behavior attached to non filmloop sprite in channel"&&spritenum&", frame"&&the frame
return
end if
if not integerP(val) then
set val = integer(val)
end if
case prop of
#sound:
if voidP(val) then
val = not (the sound of member filmloopMem)
end if
if the sound of member filmloopMem = val then
return
end if
set the sound of member filmloopMem = val
#loop:
if voidP(val) then
val = not (the loop of member filmloopMem)
end if
if the loop of member filmloopMem = val then
return
end if
set the loop of member filmloopMem = val
#crop:
if voidP(val) then
val = not (the crop of member filmloopMem)
end if
if the crop of member filmloopMem = val then
return
end if
set the crop of member filmloopMem = val
#center:
if voidP(val) then
val = not (the center of member filmloopMem)
end if
if the crop of member filmloopMem = val then
return
end if
set the center of member filmloopMem = val
otherwise
return
end case
updateLoop me
end
on getPropertyDescriptionList me
set pdlist = [:]
if ilk(me) = #script then
set sname = string(me)
set sname = word 2 to (the number of words in sname) of sname
delete char 1 of sname
delete char length(sname) of sname
delete char length(sname) of sname
if sname = "" then
alert "Make sure your scripts have names!"
return
end if
if the number of member sname < 1 then
return
end if
end if
set csn = the currentspritenum
if csn > 0 then
set mem = the member of sprite csn
set mn = the name of mem
if the type of member mem <> #filmloop then
put "Warning! Filmloop controller behavior attached to non filmloop sprite in channel"&&csn&"!"
set framecount to 999
else
tell sprite csn to set framecount to (the lastFrame-1)
end if
end if
addprop pdlist, #loopTimes, [#comment:"Loop how many times (0 for indefinite)", #format:#integer, #default:0, #range:[#min:0, #max:999]]
addprop pdlist, #framePause, [#comment:"Pause for how many frames between loops", #format:#integer, #default:0, #range:[#min:1, #max:999]]
addprop pdlist, #loopBackTo, [#comment:"Loop back to frame", #format:#integer, #default:2, #range:[#min:1, #max:framecount]]
return pdlist
end getPropertyDescriptionList
on getBehaviorDescription
set str = ""
set str = str&"• Filmloop Controller behavior •"&return
set str = str&""&return
set str = str&"This behavior allows considerably more control over filmloops than is commonly assumed "
set str = str&"possible. "&return&"It enables a filmloop to play a specified number of times, "
set str = str&"it allows a delay (in frames) between each loop, it allows the filmloop to loop back"
set str = str&" to somewhere other than the first frame and it also allows filmloop "
set str = str&"properties to be set and updated immediately."&return
set str = str&""&return
set str = str&"To trigger the loop, resetting all counters, use this lingo:"&return
set str = str&"sendsprite filmloopsprite, #triggerloop"&return
set str = str&""&return
set str = str&"To set the filmloop castmember properties, use the following:"&return
set str = str&"sendsprite filmloopsprite, #setFilmLoopProp, prop, val"&return
set str = str&""&return
set str = str&"...where prop can be #sound, #loop, #crop and #center. These properties "
set str = str&"correspond closely to the checkboxes and radio buttons in the filmloop castmember "
set str = str&"properties dialog box."&return
set str = str&""&return
set str = str&"val should be a boolean, i.e. either true or false. If no value is given, "
set str = str&"the message acts as a toggle to that property."&return
return str
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA