Skip to main content
Known Participant
January 6, 2022
Answered

Toggling audio on and off with variables on several slides

  • January 6, 2022
  • 1 reply
  • 478 views

Hello everyone:

I need help with a project that has seven slides. Each slide has three audio buttons (vocab_audio_1_1, vocab_audio_1_2, vocab_audio_1_3). Each button has two states, normal (play audio) and visited (stop audio).

1. Initially, I set three variables (audio01, audio02, and audio03) each with an initial value of 0. Each slide has an advanced action script that resets all three variables.

2. I created an advanced action script with conditional (see screen shots). When one audio button is clicked, the audio plays and the visited states shows up. In addition, the other two audio buttons change to normal state.

3. I tested that action script and it worked fine on the first slide. Then, I decided to convert it to a shared script.

4. I used the shared script for all the slides (changing the select variables), but when moving to the second and other slides, the toggling action did not work properly. 

5. I added variables for each audio button, but it didn't work.

 

Any suggestions?

 

Sincerely,

 

 

    This topic has been closed for replies.
    Correct answer Lilybiri

    May I repeat my questions, because I didn't get the expected answers. I will try to rephrase them:

    • Do you use the variables for any goal? As mentioned, I don't see any use for them.
    • Why do you insist to have a shared action.  There are indeed many advantages, will not elaborate too much. Check my most recent workshop about Shared and Advanced actions on the AEW21 conference. The video is still available: Custom Interactions Workshop - Learn All About Shared and Advanced Actions by Lieve Weymeis - eLearning (adobe.com)
      You'll see that I have more reasons than the one mentioned by Rod Ward to replace duplicate advanced actions by shared actions. However in your case you would have too many parameters.
    • In my previous answer I mentioned that you have already at least 12 compulsory parameters. If you still insist to need the variables for some reasons, and you want to have different variables on each slide, that would add 3 more parameters for a goal which is still unclear to me.
    • Is the 'Visited' state an Inbuilt or a Custom state?

    Do I have better ideas about a possible shared action? Sure, I do have some but want first to get answers to my questions. If possible I would either replace the state changes by show/hide workflow (where you can group) to get rid of some parameters, or (if possible, since I don't know which type of state 'Visited' is) replace the Change state command by Go to Next state. That is possible (like the Toggle command) if you have only two states and the Visited state is a customs state which would replace the Normal state. As Rod points out, you may not need a conditional decision at all as well but that also depends on your answer about those variables. Anyway the variables - if necessary - should be reused on each slide.

    Due to what I mentioned about the great amount of parameters, you would need a very solid labeling discipline, because all those parameters need a different name on each slide. 

    1 reply

    Lilybiri
    Legend
    January 6, 2022

    It is much easier to read an advanced conditional action if you use the Preview window. I am not sure that the action - THEN part - is complete because I see a long scroll bar. The Preview is opened by the first button in the top right control panel of the Advanced Actions dialog box. See:

    http://blog.lilybiri.com/advanced-actions-dialog-box-in-captivate-2017

     

    What is the functionality of those variables? I don't understand why you want them at all. The command 'Stop triggered audio' is unnecessary as well.  I may misunderstand but from the description I learned that you want to have three buttons. The  button needs to play an audio clip, and while playing a 'visited' state should appear. When you click another button the first button has to return to the normal state. I suppose it is not a real 'visited' state which is an InBuilt state, but you have a custom state which could be called 'Active'. The InBuilt visited state is appearing automatically when you have clicked a button.

    There is no need for the Stop triggered audio, because the Play Audio command automatically will stop any other audio clip which has been started with 'Play Audio' command. Any other audio clip (slide audio, object audio) doesn'tt listen to Stop Triggered audio.

     

    The only reason you could need Boolean variables would be that you had a second decision which would execute another series of commands when all audio buttons have been clicked (Forced view situation: learner has to listen to all audio clips before the Nextt button appears).  But that is clearly not the case, since you are resetting the variable to 0 all the time...  Maybe you have something in mind, but I need to understand.

     

    As for shared actions (my real specialty): what did you define as parameters? If there is some reason for the variables to exist, they could be reused on each slide, do not need to be parameters. If the switch for the states is necessary, you need to have both the button and the two states as parameters. Of course the audio clips need to be parameters as well. With the present setup (3 buttons) that means the necessity of too many parameters (12 parameters) to make a shared action a good choice:

    1.  Three buttons
    2. Three audio clips
    3. For each button two states = 6 parameters

    As I menttioned before, I don't see the goal for using variables, but if you have a solid reason, you don't need variables for each slide. There is a serious risk of choking your project, reuse the variables at least. 

     

    BTW: Actionscript was used for SWF output, the present advanced/shared actions are converted to JavaScript on runtime.

     

    grcutzAuthor
    Known Participant
    January 6, 2022

    Thanks Lilybiri.

     

    You helped me better understand the use of variables (and find the preview button).

    I modified the advanced action script (see screen shot). I converted it to Shared Action.

    1. It works on the first slide (first three audio buttons).

    2. I reset the same variables on every slide to 0,

    3. From the second slide on, the audio on each button plays the first time, but when another audio button is clicked, and I go to the previous button, the audio doesn't play. I need to click more than once for the audio to play again. That is my issue. 

     

    If you have a better approach, please share the script.

     

    Sincerely,

     

    RodWard
    Community Expert
    Community Expert
    January 7, 2022

    You should only convert an Advanced Action or Conditional Action to a Shared Action AFTER you have made sure it all works as expected.  You need to debug everything first because Shared Actions cannot really be modified easily.

     

    I also don't see why you need to be using any variables in this case.  To me it seems like all you should need to do is have the click event on each button Play the audio for that button and set the other two buttons to their inactive (non-audio) states at the same time.  You would not even need a Conditional Action to do that.  Just an ordinary Advanced Action with multiple actions one under the other.

     

    Variables and Conditional Actions are only really necessary if the actions performed need to be dynamically changed at run-time in response to some change by the user.

     

    But if you think the variables ARE essential, then you need to know what the values of all variables in the Conditional Action are at runtime so that you can see what is happening and then debug the interaction.  You can do that by adding some Text Captions or Smart Objects to the slide with the variables inserted into them so that the variable values become visible at runtime.