Replay (slide) Button

Update:

A new version of these workflows (for CP2019) can be found in a new post and in an interactive Captivate tutorial.

Replay or Reset Slide

Replay/Reset (Captivate course)

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.