Replay (slide) Button

Intro

This pretty short article will explain several ways to create a button that will replay a slide from its first frame and is functional on that slide only. The reason is that I have been asked about this use case multiple times. 

Questions

First thing to check is: does this slide have an On Enter action? The default On Enter action for a slide is 'No action'. On Enter actions are however the way to go if you want to reset a slide to its initial configuration, to clean up the 'mess' that can happen on that slide by the user or by the interactivity on that slide. On example: maybe the user has popped up objects  using a hyperlink on a word or iimage? In that case you'll need an On Enter event. The action needed for a Replay button will have to make sure to 're'- enter the slide, in order to have that On Enter action done. To better understand what I mean, I created a short example movie.

Example movie

Watch this movie, which I have been testing both for SWF (version here) and for HTML5 output. You'll see two slides:

  1. Slide 'Title': it has an On Enter action to play an audio clip.

  2. Slide 'Pills': a user variable v_counter is used (and displayed) to store the number of clicks on the 'pills'. The timeline of this slide looks like this

    Each of the pills (shape buttons) triggers a shared action, that will show a state (with explanation), increment v_counter, wait for 2 seconds before releasing the playhead.

On both slides you'll see two buttons: 'Replay1' will restart the slide from its first frame, without re-entering the slide. That means that the On Enter action is not executed again. The second button 'Replay2' will re-enter the slide. Listen and watch the difference (look at the counter on the second slide). Refresh the browser when you are ready to watch this example. Refreshing will also get you back to the start of the movie.

'Replay1' - On Enter action is not repeated

If you do not need a resetting action On Enter, a replay button can be coded very simple. If you are on the slide with the label 'Intro', this simple code will do the trick:

    Jump to slide Intro

However you'll not find the slide 'Intro' in the dropdown list for the 'Jump to' command in the Actions tab. You need to choose 'Execute Advanced Action', and create a one-line standard advanced action.

It is simple but I do not recommend to use this work flow. It means creating a new advanced action for each slide. A first alternative would be a shared action, defining the slide name (or number) as a parameter.

If you need this action for many, even all slides in a project, there is a much better work flow. Create this advanced action:
  
Why do you need an expression to subtract 1 from the number of the current slide, which is stored in cpInfoCurrentSlide? The index of the system variable cpInfoCurrentSlide starts by 1 That way it can be inserted on a slide indicate the slide number. Its value for slide 3 is '3'. To show the slide number you insert cpInfoCurrentSlide in a text container on the master slide or timed for the rest of the project.

The index of system variable cpCmndGotoSlide starts not by 1, but by 0 (usual in programming languares). If you want to navigate to slide 3, you have to give a value '2' to cpCmndGotoSlide.  So far the reason for that Expression in the advanced action Replay1.

This command is functional both for SWF and HTML5 output. I tested this in several browsers.

This action is triggered by both Replay1 buttons in the Example movie. The On Enter action is not executed with this Replay, which results in:
  1. For slide 'Title': the audio clip will not be heard.
  2. For slide 'Pills': the variable v_counter is not reset to 0, and will continue to increment.
Watch the variables I inserted top left of the slides: they show the current frame, and the frame number stored in the user variable v_enter.  If you wonder why the frame number never starts with 1, read the explanation under the next subject 'Replay2'.

TIP

be sure to create this action as a shared action, no need to define the system variables as parameters. Store that action with much used shared actions in a separate project. In any project you can open the Library of that project as an external Library and drag that Replay action to the library of the new project.

Replay2 - On Enter action is repeated


As explained under 'Questions', you'll have to enter the slide in this case, not just jump to the first frame as was done with the Expression in the scenario for 'Replay1'.

This is a bit more complicated. I had to use 'micro-navigation', a term introduced by me in this old  blog post: navigating between frames. Look at the advanced action created for the 'Replay 2' buttons:
This is the work flow:
  • Create a user variable v_enter that will be reused on each slide that needs a Replay button of this kind. That variable will store the number of the first frame of the slide. To achieve that I have to add a command to the already existing On Enter actions. Here are the actions for both slides:

  • When the Replay button is clicked, there is first navigation to 2 frames before the first frame of the present slide. Why 2? Theoretically 1 frame should be OK, but for HTML5 output (slower) I learned that it is better to use
  • Although I use the system variable cpCmndGotoFrameAndResume for navigation, which should release the playhead and navigate very quickly to the next slide, I detected that adding the second command 'Go to Next Slide' made the process more fluent (again for HTML5 output). 
The result is very clear in the Example movie:
  1. For slide 'Title': the audio clip is played
  1. For slide 'Pills': the variable v_counter is reset to 0.

Frame enigma - TIP

If you watched the frame number closely, you will have seen that the 'first' frame (on slide 'Title') is not 1 but 3 or 4. Here is the explanation: since I wanted the Replay2 button to be active on this first slide, I needed a slide before that first slide for the micro-navigation. That slide will not be visible to the user because it is only 0,1 sec long. At a frame rate of 30fps, that means ...3 frames.



23 responses
Thanks for sharing your wisdom again with us Lieve!
I have needed replay buttons before, but I have never come up with as elegant a solution as the two options you explain here. I will definitely be able to use this. Thank you!
Dankjewel, Vico!
Whow, 'elegant' is a nice word for my solutions. I like them as well, they are in my Scripts Library.
So many great tips on here and on the forums by you! I am in your debt. Thanks a lot!
Hi Lieve. Great solutions here. I've been having trouble with a video continuing where left off. I have an interactive video that I've created where the video plays, then pauses for a learner to interact and show a popup (the popup has a continue button to continue the video). This all works fine. However I have another button later in timeline that takes the user to slide 2 for other content. On this slide is a button to return to the video slide (Slide 1). I can get the slide to resume at the right frame, however the video appears to replay. If you've done this before I'd love to hear your solution. Cheers, Ray
Please, Ray, post your question on the Captivate forums.
Great post, thanks. I've been able to "wow" everyone at work with these slide reset techniques.
Thanks, I'm used to a lot of 'wow' reactions with every training I'm offering, whether on this blog, online or F2F.
Hello Lieve. Your solution for "Replay2" button is not working when publishing for HTML5. (Using CPTX 9.0) It just jumps to the next slide.
I have extensively tested the solution for HTML, both Preview and Published because there are easier solutions for SWF output which do NOT work for HTML. Just double-checked and the Replay2 is working perfectly for me, in Chrome and Firefox. Which browser did you use to test?
@ Lieve: I tested it in 3 browsers: Chrome, Firefox, Safari. Is it OK if I send you this little test-project?
No, sorry, I do not accept files. I am pretty sure of the functionality of both buttons, have used them for several clients, also for HTML output. It looks also very strange that you are the only one reporting this issue. I suspect something is wrong with your file. You can always try to get help on the Adobe forums, but this is just a blog where you can find tutorials for free.
Thanks for the post. It took me a few goes before I got something working but I'm clearly seeing a flash of the previous slide before the slide refreshes. I have an swf animation on my slide that I want to simply loop but the Loop checkbox (under Timing) isn't doing squat so I've had to turn to using a button that does the slide refresh option. If I don't do the minus frames, like you show us, and try to start at frame 0 or 1 the swf animation just doesn't refresh, but if I set the action to -1 frame (or more) I still see a flash of the previous slide before the current slide refreshes (a little visually disturbing). The mind boggles why Adobe haven't provided a simple way to achieve this... (among other Captivate annoyances)
You could try to add short fade out transition to the previous slide objects. That flash will not be visible on every device, but it is possible.
Hi Lieve, I agree with Dieter, Replay2 is not working in Captivate 9 HTML5. It jumps to the next slide (as Dieter also mentioned). All other variation that I tried in the advanced action do have the right effect either. Moreover, a question on that page will also not be reset by the replay-actions. Again one of the (many) annoyances of Captivate?
Rolf, when I wrote this post, both scenarios were working perfectly in HTML5 output. I even used it several times for clients (Replay2). I left out an even easier version for the first scenario because it only worked for SWF output. That it is broken again with a more recent version is not the first time. If I had 24hrs a day I could perhaps screen every post whenever a new release got out, to see what is broken. Sorry for the inconvenience, but everything is free here.
Dieter and Rolf, same bug is still present in Captivate 2017 (logged it): when using micronavigation the On Enter action is not executed for HTML5 output. There is a workaround, will describe it extensively in a future blog post (using short dummy slides).
Lieve, thank you for your comment. Several weeks ago I already tested the workaround with short dummy slides, it works nicely. The only disadvantage (and the reason that I don't use this solution) is that the slidecounter I show on any slide is no longer usable, because it also counts the dummy slides. Instead I use your Replay2 option, without the "Go to Next Slide". It works fine in HTML5, taking a short "flicker" of the previous slide for granted.
Rolf, the flicker could be solved if slide transitions were functional for HTML5 but they aren't. I sincerely hope this bug will be fixed one day. Did you log it as well? It is the only way to get the fix on the priority list of the engineers.
Lifesaver, thank you so much!
You're welcome :)
1 visitor upvoted this post.