• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can I create a button that will take me to a random slide in a sequence?

Community Beginner ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Let's say I have three simulations setup and the simulations start on slide 5, 15, and 23. Can I make a button that will randomly jump to one of those slides?

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Maybe by generating a random number with JS, store it in a user variable and use that to jump. Which output format: SWF or HTML?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Sreekanth, it is about jumping to a random slide, not to a specific slide in another Captivate file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Hmmm, ok.

If you want to use Lilybiri's solution, the JS to generate random number is here.

http://forums.adobe.com/message/5940975#5940975

Sreekanth

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

Using the random number can I limit the possible numbers it chooses to the three main slide numbers? Or will it put every number between 5 and 23. (Numbers from my example)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

This will do what you want:

<script>
function shuffle(arr) {
  for (var tmp, cur, top = arr.length; top--;){
    cur = (Math.random() * (top + 1)) << 0;
    tmp = arr[cur]; arr[cur] = arr[top]; arr[top] = tmp;
  }
  return arr;
}

var arr = [5, 15, 22];

shuffle(arr);
var startSlide = arr[0];
alert(startSlide);
</script>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

I will give it a try. Thanks for the help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

I tried this, but it just jumps to the next slide in the presentation. I previewing it in the browser, and I set the script to execute as JavaScript. Is this correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

You are seeing the default action of a button. Guess you forgot to associate the script with the button.

Sreekanth

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

You have to execute that script using an event, in this case you'll use the Success event of the button that you created to 'jump'. And it will probably be an advanced action, unless you execute the JS with the On Enter event of the slide. You have two commands: first to execute the script, second to jump to that slide, for which you'll have to use a system variable cpCmndGotoSlide and the value of the variable returned by the JS. Slide numbering starts with index 0.

http://blog.lilybiri.com/system-variables-in-captivate-6

http://blog.lilybiri.com/events-and-advanced-actions

Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

use a system variable cpCmndGotoSlide and the value of the "variable"...

From AFdevelopers script what would be the variable that is returned? startSlide?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

Put this in the html head:

function shuffle(array)

{

var arr = array.split(",");

   for (var tmp, cur, top = arr.length; top--;)

{

  cur = (Math.random() * (top + 1)) << 0;

  tmp = arr[cur];

  arr[cur] = arr[top];

  arr[top] = tmp;

   }

   //myStart = arr[0];

Captivate.cpEISetValue("cpCmndGotoSlide", arr[0]);

}

Then, in the javascript window in captivate:

shuffle("4,14,22")

change the numbers evertime you want to call the function, make sure they are in quotes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

Is this correct?

Capture.PNG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

No, you need to surround it with <script></script> tags. I would move it to be the last thin in the head section.

<script>

function shuffle(array)

{

var arr = array.split(",");

for (var tmp, cur, top = arr.length; top--;)

{

cur = (Math.random() * (top + 1)) << 0;

tmp = arr[cur];

arr[cur] = arr[top];

arr[top] = tmp;

}

//myStart = arr[0];

Captivate.cpEISetValue("cpCmndGotoSlide", arr[0]);

}

</script>

</head>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

@AFdeveloper, this is only valid for SWF-output, right? Sreekanth pointed to a thread where both outputs were included, and it returned the random value. That is why I talked about adding an advanced action to jump to the random slide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

LATEST

True,

If you change the line:

Captivate.cpEISetValue("cpCmndGotoSlide", arr[0]);

to:

if (cp)

{    

     var getSlides = cp.model.data.project_main.slides;
     var slideArray = getSlides.split(',');

     for (i = 0; i < slideArray.length; i++)
      {
       slideArray= slideArray.replace('Slide',''); 
      }

    

     cp.jumpToSlide(slideArray[arr[0]])

}

else

{

     Captivate.cpEISetValue("cpCmndGotoSlide", arr[0]);

}

It works with HTML5 output as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

Put this in the Head section of your html, then call the javascript; shuffle() on the action attached to the button.

<script>

function shuffle()

{

var arr = [4, 14, 22];//this is the array of page number,s zero-based, Slide 5 = 4

   for (var tmp, cur, top = arr.length; top--;)

{

  cur = (Math.random() * (top + 1)) << 0;

  tmp = arr[cur];

  arr[cur] = arr[top];

  arr[top] = tmp;

   }

   Captivate.cpEISetValue("cpCmndGotoSlide", arr[0];);

}

</script>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2014 Jan 14, 2014

Copy link to clipboard

Copied

I don't think I can do it that way. I need to add three or four of these types of buttons in the project. Each button would need to call upon a different set of slides.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

No

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2014 Jan 13, 2014

Copy link to clipboard

Copied

HTML

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources