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

Run Javascript within Shared Action

Community Beginner ,
Jul 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Hey everyone - so I have been using Javascript, Shared Actions, and other advanced coding topics for a while now in Captivate 2019 or Captivate for Developers as I think of it (whilst 2023 is Captivate for Designers).

 

I have a project that is about 70 slides long and plays audio on 50 of them.

 

It is easy enough to get audio to play per slide. My issue is that on each OnEnterFrame I fire a Javascript function that controls the length of a completition bar per slide. Because I can only fire one thing per OnEnterFrame, I began looking for solutions. 

 

a) attach the audio to an invisible shape per slide. The first audio plays. Subsequent do not. 

b) create a shared action - using an advanced action that fires the Javascript then plays the first audio file, I then created a shared action that would (I assumed!) allow me to set the javascript then ask for which audio to play. Of course it didn't work that way and even though the Select which audio to play appeared, the javascript code was not there.

c) I could creat a pure javascript method but I am thinking of other developers on my team who are not so versed in JS and I would like as much an in house to Captivate solution as possible. 

d) I could create one advanced action with a Decision IF statement per slide that requires audio. If variable = 0 play first audio, then increment variable to 1. Subsequent call of advanced action, if variable = 1  etc...

Except Captivate with decisions excecutes ALL Decisions at once. I've never found a way for Captivate to stop executing decisions once a positive match is made for the IF statement. 

d) finally there is the sledgehammer choice - from my perspective the overkill which is ONE Advanced Action per slide that fires the javascript then the appropriate audio. 

 

From a programming point of view D is ridiculous. Is there any other way of doing what I feel is quite simple?

 

thanks

TOPICS
Advanced , Advanced actions

Views

79

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 ,
Jul 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Update - so I saw mention of putting the audio on the timeline but ensuring there was a small gap between the start of the timeline on a slide and the audio itself... voila.... the second audio played. I'm going to test this some more. 

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 ,
Jul 26, 2024 Jul 26, 2024

Copy link to clipboard

Copied

So strange that I didn't see this question at all? I have created shared actions in which JS was executed but there are some limitations:

Game: using JavaScript in a Shared action - Captivate blog (lilybiri.com)

Version 12 is Captivate for dummies.... not even for designers.

The recommendation about the gaps was probably from me, it is to avoid loss of synchronisation between the slide timeline and the audio clip which needs to be loaded on entering the slide.

I am not sure to understand your situation very well. The JS fires on each frame? But you cannot launch a audio clip on each frame. Can you please try to tell as simply as possible what you exactly want to do?  You can create a progress bar per slide with motion effects, but I understand that is too much work if it needs to be done for multiple 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 ,
Aug 05, 2024 Aug 05, 2024

Copy link to clipboard

Copied

LATEST

Hey - no, the JS fires on each onEnterFrame on each slide. There is a function in the first slide that works out How many slides there are, divides a static amount (the final length of the progress bar on the final slide) by this amount of slides which equals amount to increase the progress bar object per slide. EG 1000 / 10 slides = 100 pixels per slide increase. 

On each OnEnterFrame, a function is run to update the progress bar by the amount determined eg 100pixels in this example. But I wanted to find out if I could create a Shared Action that allows me to select an audio file to play and a javascript function to fire. But I could not get the Shared Action to accept using javascript. I've had a look at your example which shows the idea working but I couldn't see any screenshots of how the Shared Action is built unless I'm missing something.

 

thanks! 

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