5 Replies Latest reply on Dec 8, 2006 11:51 AM by Newsgroup_User

    Stop timeline exactly where it is

    layerburn
      I need help with stopping the timeline and audio exactly where it is when my pause button is pressed. The pause changes to a play button which on release I want to pick up from exactly where it is on the timeline and in the audio. Can this be done?? Would it be a function for when the button is pressed? I'm fairly good with general scripting, but I didn't know if this could be done or if it was something really advanced. If anyone could help me I would greatly appreciate it. Thanks for you time and guidance.
        • 1. Re: Stop timeline exactly where it is
          Level 7
          layerburn,

          > I need help with stopping the timeline and audio exactly
          > where it is when my pause button is pressed. The pause
          > changes to a play button which on release I want to pick
          > up from exactly where it is on the timeline and in the
          > audio. Can this be done??

          It sure can, but the exact code depends entirely on how you've set up
          your FLA. Is this audio laid into a layer directly? If so, you'll need to
          set its Sync setting to Stream (see the Property inspector with the audio's
          initial keyframe selected). In that case, all you have to do is halt the
          timeline and resume it again.

          Is the audio controlled via ActionScript (the Sound class)? If so, the
          required coding is only marginally more elaborate, because you have to both
          halt the timeline and halt the Sound object.

          Write back with your details, and I'll help you out.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Stop timeline exactly where it is
            layerburn Level 1
            Thanks so much for the help. I'm using a variable to bring in my sounds, so there outside the fla in a folder. This is how I have it scripted. I do have a mute button, but my client also wants a pause button that will just pause things exactly where they are, both timeline and audio. Again thanks for the help.


            • 3. Re: Stop timeline exactly where it is
              minaminasaywhat
              I was actually about to post the same question!! I have a main Flash file (start.swf) that serves as the main timeline for a presentation. It pulls 8 other external swfs in the timeline - to keep file sizes down. Each external swf also dynamically calls exteral flv videos, xml files (so my client can edit text), MP3s, and JPGs via ActionScript. Nothing too complicated.

              I call each of the 8 external swfs 'pages', and I've created a controller that has BACK, PAUSE/PLAY, and FORWARD buttons. I know you can control the playback of FLV files, but I have my audio being called with AS the same way as layerburn, and I also have multiple timelines to consider (the start.swf main timeline, the 8 pages' timelines, the flv video timelines, and the audio).

              I have the FWD/BACK buttons working (this just goes to the next-previous page/swf in the start.swf file), but my client wants to be able to actually pause the program in the actual spot, rather than the beginning of the section.

              Does anyone have a good suggestion as to how to control/combine play and pause functionality with multiple timlines?

              • 4. Re: Stop timeline exactly where it is
                layerburn Level 1
                I found my way to your blog David and found your article on pausing sound, it was exactly what I needed.

                pause_btn.onRelease = function() {
                dynamic_sound.start(dynamic_sound.position / 1000);
                }

                However, how would i refterence my pause_btn if it is nested in a movie clip called pauseNplay?? That way I can have a toggle button that is a pause and play button.
                Also I was curious about pausing the actual timeline exactly where it is. That part I haven't figured out yet. I have the pause timeline code that uses an interval to count off so many seconds, but how do I script it to acknowledge the pause and subtract the time that has already been counted to resume and finish the count to continue on?? Because in a sense in my project it has an autoplay mode where it uses the intervals to count so long and then progress. So i still need these to work with the pause feature. So the user can have the autoplay run, but pause and resume if need be. Thanks so much for the help. I appreciate deeply.
                • 5. Re: Stop timeline exactly where it is
                  Level 7
                  layerburn,

                  > I found my way to your blog David and found your article
                  > on pausing sound, it was exactly what I needed.

                  Cool. Glad that helped.

                  > However, how would i refterence my pause_btn if it is nested
                  > in a movie clip called pauseNplay??

                  You could either make pauseNplay a "button," even though it's a movie
                  clip. Note in the "MovieClip class" entry of the ActionScript 2.0 Language
                  Reference that movie clips support many of the same events as the Button
                  class. (Classes define objects in ActionScript, and they serve as terrific
                  Owner's Manuals for the object in question. See the "First Time Here?" link
                  on my blog for what I hope are some helpful articles.)

                  Or ... you could simply path to it. Rather than ...

                  pause_btn.onRelease = function() { ... }

                  ... it sounds to me like this might be ...

                  pauseNplay.pause_btn.onRelease = function() { ... }

                  Objects paths are a lot like folder paths on your hard drive.

                  > Also I was curious about pausing the actual timeline exactly
                  > where it is. That part I haven't figured out yet.

                  For that, you simply need the MovieClip.play() and MovieClip.stop()
                  methods -- you'll see those in the MovieClip class, as well. Even the main
                  timeline is a movie clip, so those work there, too. Just add another line
                  inside your button handler ...

                  pauseNplay.pause_btn.onRelease = function() {
                  dynamic_sound.start(dynamic_sound.position / 1000);
                  this._parent._parent.play();
                  }

                  Keep in mind, I just made up this._parent._parent, because I have no
                  idea where your main timeline is in relation to this button. Both buttons
                  and movie clips have a _parent property that points to the object that
                  contains them. this._parent._parent might just point to your main timeline,
                  if pauseNplay is located there. Pathing makes sense once you wrap your head
                  around it.

                  > I have the pause timeline code that uses an interval to count off so
                  > many seconds, but how do I script it to acknowledge the pause
                  > and subtract the time that has already been counted to resume and
                  > finish the count to continue on??

                  The getTimer() function tells you how many milliseconds have passed
                  since the movie began. When you go into pause mode, you could store the
                  current value of getTimer() in a variable, then retrieve that number and
                  peform math on it to make decisions in the future.

                  It sounds like you might benefit from picking apart each of these pieces
                  and mastering them on their own. When you have solid footing, it helps make
                  sense of them when you combine them in (possibly) complex ways.


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."