Skip to main content
February 11, 2017
Question

How execute a advance action at the end of slide?

  • February 11, 2017
  • 3 replies
  • 2274 views

Hello,

Please tell me how to How execute a advance action at the end of slide in captivate?

    This topic has been closed for replies.

    3 replies

    Paul Wilson CTDP
    Community Expert
    Community Expert
    February 12, 2017

    Generally I will execute an advanced action that I need to run on exit through my go to next slide button. For example, I have a template with a custom table of contents I need to close every time someone exits a slide.  Instead of simply going to next slide just add your advanced actions before the next slide command and you are ok. If your advanced action is conditional just add the go to next slide command at the end of your on condition action as well as your ELSE actions. 

    Paul Wilson, CTDP
    Lilybiri
    Legend
    February 12, 2017

    Paul, you talk about an action that is triggered by a button, not about an advanced action that is executed (automatically) On Exit for a slide. The user needs to click on the button to have this action done. It will not be done when leaving the slide, after the last frame, but on the frame defined by the pausing point of the button.  In that case the On Exit event of the slide doesn't occur at all as I explain in detail in the blog post about events. More info about the pausing points vs a Pause command triggered by a slide event in:

    Pausing Captivate's Timeline - Captivate blog

    Captivate has at this moment no event 'on leaving the slide', which is not the same as 'on exit'.

    Paul Wilson CTDP
    Community Expert
    Community Expert
    February 12, 2017

    Thanks for your concern but I was not talking about a single action. My course designs do not use the inbuilt Playback Control nor do they use the inbuilt Table of Contents. Instead, I create my own. Because of this, I cannot use a single action for any button that navigates away from any slide. Instead, I have created several advanced actions that contain the Go to Next Slide command but also contain the other actions that I need to be performed. Here you can see an example of that for the Next button on a slide from a recent course I am developing. I still call them Goto_Next_Slide but the advanced action takes care of some additional housekeeping that needs to occur. 

    2017-02-12 12-53-46 PM

    Yes, these advanced actions are not being run on the final frame of a slide but since my navigation controls are the only way a user is going to exit one of my slides, for all intense purposes they are the last frame of that slide the end user will ever see. To me, this is the simplest way to achieve this and to guarantee that the set of actions runs. This works very well and is fully tested on many courses.

    Paul Wilson, CTDP
    TLCMediaDesign
    Inspiring
    February 11, 2017

    You can do this with JavaScript utilizing the CPAPI_VARIABLEVALUECHANGED event listener while monitoring the cpInfoCurrentFrame variable.

    The advanced action needs to be attached to some object to work. I created an invisible smartshape named "action_1" where the number indicates the slide number. make it 4x4 pixels, double-click, put it in a corner or the slide, no hand cursor.

    You can then put one on any slide you need to use it by attaching an advanced action and changing the numberin the name to match the current slide, i.e. "action_2", "action_10"

    This script will need to be put in the head of the index.html.

    var interfaceObj, eventEmitterObj, slideEnterData;

    window.addEventListener( 'moduleReadyEvent', function ( e )
    {
    interfaceObj = e.Data;
    eventEmitterObj = interfaceObj.getEventEmitter();
    initializeEventListeners();
    });

    function initializeEventListeners()

    if ( interfaceObj )
    {
      if ( eventEmitterObj )
      {
       eventEmitterObj.addEventListener( 'CPAPI_SLIDEENTER', function ( e )
       {        
        slideEnterData = e.Data;  
        eventEmitterObj.addEventListener( 'CPAPI_VARIABLEVALUECHANGED', runTimer, 'cpInfoCurrentFrame' );   
       });
      }
    }
    }

    function runTimer( )
    {
    if ( window.cpInfoCurrentFrame == slideEnterData.to - 1 )
    {
      cp.runJavascript( cp.model.data[ 'action_' + slideEnterData.slideNumber ].oca )
    }
    }

    Participant
    April 14, 2021

    Hi! This seems like the solution I need. Does the smart shape need to be converted to a button to attach the advanced action?

    TLCMediaDesign
    Inspiring
    April 15, 2021

    Yes, it does need to be a button.

     

    I would probably do this a little differently now. But this should still work.

    Lilybiri
    Legend
    February 11, 2017

    There is an On Exit event for slides, but I really do not recommend to use it unless you are totally sure that the last frame of that slide will always be visited, and after extensive testing. Have a look at:

    Events and (advanced) Actions - Captivate blog

    Personally I rarely use that event to trigger an advanced or shared action, especially for navigation I will prefer the On Enter event of the following slide. If you gave more details about which action you want to execute, could offer more recommendations.