Skip navigation
Currently Being Moderated

Creating own controller

Apr 22, 2012 1:36 PM

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

 
Replies
  • Currently Being Moderated
    Apr 22, 2012 3:51 PM   in reply to bmohnsen

    When you say

    I have tried go to the frame for stop --- and even put it in a loop - but it doesn't stop

    are you talking about your Director movie or a video file you have playing on the stage?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 12:57 AM   in reply to bmohnsen

    And so you're wanting a controller something like the QuickTime controller, with a play/apuse button and a sliding scrub bar?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 11:31 AM   in reply to bmohnsen

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points