Skip to main content
Participant
September 30, 2017
Question

jump to specific slide using javascript

  • September 30, 2017
  • 2 replies
  • 1628 views

I'm working on a project and I want to create a "menu" in adobe animate CC with some animations and three buttons (one for each chapter).

As of now everything is working but I want to tweak it a little because every time I'm adding a slide or removing one in captivate (client wants to make changes as we're working and I know I can wait until the slides are finished to change the numbers but I just want to know if its possible for future projects) I have to go back to Animate CC and change the slide numbers I want to jump to while clicking any of the chapter buttons. 

My question is: is it possible to use a go to slide name instead of number?

 

right now I'm using this for my first chapter button in animate:

this.chapter1_btn.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()

{

window.parent.cpAPIInterface.

gotoSlide(2)

}

 

if it's possible to go to a named slide instead of a slide number I could name the slides to chapter_1, chapter_2 and chapter_3, publish the oam file and import it in captivate and then ad or remove content slides within that chapter without going back and changing the slidenumbers i want to jump to in  Animate CC. 

 *the "2" in the "gotoSlide(2)" is actually slide three in captivate, not sure why it is the slidenumber - 1. 

 

/Johan

This topic has been closed for replies.

2 replies

Inspiring
September 28, 2018

I can't take credit for writing this piece of code (not that well versed yet), but this should do the trick - 

function jumpSlideLabel(which){

var idx = 0;

var getSlides = window.parent.cp.model.data.project_main.slides.split(",");

 

for (var i=0; i<getSlides.length; i++) {

if (window.parent.cp.model.data[getSlides].lb===which) {

window.parent.window.cpCmndGotoSlide = i;

window.parent.window.cpCmndResume = 1;

break;

}

}

}

 

then call it - 

jumpSlideLabel("SlideNameHere");

Lilybiri
Legend
September 30, 2017

I always use advanced/shared actions, am not a JS expert. I always use the slide name with Jump To, so I think it should be possible with JS as well.

Your question about the variables. Some versions ago there were two system variable for slide numbers, one with index starting at 0 (rd variable) and the one that is now the only exposed one, starting with index = 1 (cpInfoCurrentSlide). I suspect JS is using the first variable, index starting with 0, like most system variables of that type.