There are parts of my movie where I want the user to have complete control. So I created a controller with step back, pause, step forward, play.
Any help with script would be appreciate. I have tried go to the frame for stop --- and even put it in a loop - but it doesn't stop
I have tried frame+1 for step forward without any lock.
How do control frame movement.
I would prefer not to use markers - because the count would be in the thousands.
Thanks
One way to approach this is to place all the logic for controling the position of the timeline in a parent script and then use a global exitFrame handler inside a movie script to route the call to an instance of the parent script.
It's simpler than it sounds.
Here's the movie script:
global gControler
on prepareMovie
gControler = script("Timeline Controler").new(#play) -- #play, #pause, #reverse. [speed] optional speed value
end
on exitFrame
gControler.updateFrame()
end
--------------------------------------------------------
Now you can control the flow of the timeline via the global object "gControler" which I provide below.
The interface is:
gControler.play(), gControler.play(3), etc
gControler.reverse(), gControler.reverse(2), etc
gControler.pause()
gControler.jump(1), gControler.jump(10), etc
gControler.seek(10), gControler.seek(1000), etc
Any exitFrame handlers in FrameScripts will override the movieScript exitframe handler. Which you may or may not want to do.
Paste the following in to a parent script named: "Timeline Controler"
-- Parent Script Timeline Controler
property pState -- #play, #pause, #reverse
property pSpeed -- frames per exitFrame. Normal play rate is 1.
on new me, aState, speed
if aState.SymbolP then
pState = aState
else
pState = #play
end if
if Not [#play, #pause, #reverse].getPos(pState) then pState = #play
if speed.IntegerP then
pSpeed = speed
else
pSpeed = 1
end if
return me
end new
-- change current frame based on state variable pState
on updateFrame me
case pState of
#play: go(min(_movie.frame + pSpeed, _movie.lastframe))
#reverse: go(max(1, _movie.frame - pSpeed))
#pause: go(_movie.frame)
end case
end updateFrame
-- go forwards
on play me, speed
if speed.IntegerP then
pSpeed = speed
else
pSpeed = 1
end if
pState = #play
end play
-- go backwards
on reverse me, speed
if speed.IntegerP then
pSpeed = speed
else
pSpeed = 1
end if
pState = #reverse
end reverse
-- loop on a frame
on pause me
pState = #pause
end pause
-- move "pos" number of frames from current position. Can be positive or negative
on jump me, pos
if pos.IntegerP then
go(max(1, min(_movie.frame + pos, _movie.lastframe)))
end if
end jump
-- go to an absolute position on the timeline
on seek me, pos
if pos.IntegerP then
go(max(1, min(pos, _movie.lastframe)))
end if
end seek
on prepareMovie
gControler = script("Timeline Controler").new(#play) -- #play, #pause, #reverse. [speed] optional speed value
end
Do you create
gControler = script("Timeline Controler").new(#play)
for pause and reverse as well?
gControler = script("Timeline Controler").new(#pause)
gControler = script("Timeline Controler").new(#reverse)
I am getting an object expected error.
Here is the code I have in my movie script
global gControler
on prepareMovie
gControler = script("Timeline Controler").new(#play)
end
on exitFrame
gcontroler.updateFrame()
end
==
Then I used the code you gave me and put it in a parent script.
==
Then I created four buttons - back, pause, play, forward
Back:
global gControler
on mouseEnter()
cursor 280
end mouseEnter
on mouseLeave()
cursor -1
end mouseLeave
on mouseup
gControler.reverse(1)
end
Play:
global gControler
on mouseEnter()
cursor 280
end mouseEnter
on mouseLeave()
cursor -1
end mouseLeave
on mouseup
gControler.play()
end
Forward:
global gControler
on mouseEnter()
cursor 280
end mouseEnter
on mouseLeave()
cursor -1
end mouseLeave
on mouseup
gControler.play(1)
end
Pause:
global gControler
on mouseEnter()
cursor 280
end mouseEnter
on mouseLeave()
cursor -1
end mouseLeave
on mouseup
gControler.pause()
end
North America
Europe, Middle East and Africa
Asia Pacific