A new version of these workflows (for CP2019) can be found in a new post and in an interactive Captivate tutorial.
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.
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.
Watch this movie, which I have been testing both for SWF (version here) and for HTML5 output. You'll see two slides:
- Slide 'Title': it has an On Enter action to play an audio clip.
- 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
Jump to slide Intro
- For slide 'Title': the audio clip will not be heard.
- For slide 'Pills': the variable v_counter is not reset to 0, and will continue to increment.
Replay2 - On Enter action is repeated
- 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).
- For slide 'Title': the audio clip is played
- 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.