Open a blank project and add a content slide.
Advanced Actions allow you to execute some complex tasks and workflows in the Captivate project when an event is triggered, or when certain conditions are met.
Assets and samples
The procedures in this document require you to use assets such as images and sample Adobe Captivate project files. You can choose to use your own assets and samples. However, it is recommended that you download and extract the following zip file to your computer:
Before explaining Advanced Actions, some basic concepts which are useful to understand Advanced Actions are covered.
What are literals?
Literals are fixed values. A literal can be either an alphanumeric value, or it can be a number. For example, in real life, John, Sarah, 100 are literals as they are fixed values.
And, for a string literal, like “John”, if you use it with any function in conventional programming, the value of the literal changes. If you want to reverse the literal above, use “John”.reverse().
What are variables?
Variables are entities whose values can change. For example, in real life, if 'color' is considered a variable, red, blue, and green are some of the values logically associated with that variable. So variables can be considered as placeholders for different values.
System variables and user variables
Variables in Captivate can be classified into system variables and user variables. Following is a brief description of them.
System variables
System variables are pre-defined variables in Captivate.
For example,
- cpInfoCurrentDate is a system variable which shows the current date that is set on the user's computer.
- cpInfoAuthor returns the name of the author as specified in the properties of the project (File > Project Info).
User variables
User variables are defined by the user. These variables can also be made to accept a set of values, and reject the other entries.
For example, you can define a variable 'fruit' to accept fruits as values. You can also restrict the values accepted by the 'fruit' variable by specifying that the entries be one of apples, oranges, grapes, or bananas. This helps you in collecting values in the variable which are of interest to you.
When you add a Text Entry Box to the slide, Captivate automatically assigns a variable to it.
To learn more on variables, see the article Adobe Captivate variables.
Creating user variables
You can create user variables in your Captivate project by choosing Variables in the Project menu. This opens up the Variables dialog box. To create a new user variable, click open Add New to the right of Type drop-down box. It's a good practice to name the variables in a way which helps you identify its function later on. You can also enter an initial value to the variable in the Value field.
In Captivate, system variables cannot be modified or deleted, and user variable names cannot be changed once created.
Rules and conventions for naming variables
The name you assign to a user variable must not conflict with Captivate’s internal functions, reserved keywords, exposed system variables, or other hidden variables.
There are some conventions while naming a variable. They are:
- Do not begin the name with a blank or a digit.
Example: Naming variables as 1Name, _Name is a bad practice.
- Do not use any reserved keywords.
For example, avoid using the keywords like: class, while, case, float.
- Use unique variable names.
Example: MyVar1, MyVar2
- Use intuitive names for a variable.
Example: Input_Name, Display_Education
- Always add descriptions to a variable.
Example: Input_Name variable accepts name entered by the candidates.
To see the list of reserved keywords in Captivate, see the article How to create user-defined variables in Adobe Captivate.
Advanced Actions
An Advanced Action allows you to execute an action when an event is triggered, or when a condition or set of conditions are met.
Advanced Actions User Interface
To open Advanced Actions, go to Project menu, Advanced Actions. You get the user interface shown below.
Label | Description |
---|---|
1 | Name of the action. |
2 | Enable this check-box to make the action conditional. |
3 | Action items. |
4 | Choose an existing action. |
5 | Preview the structure of the action. |
6 | Create an action. |
7 | Import a shared action. |
8 | Export a shared action. |
9 | Delete an action. |
10 | Duplicate an action. |
11 | Add an action item. |
12 | Delete an action item. |
13 | Copy an action item. |
14 | Cut |
15 | Paste |
16 | Insert |
17 | Move up. |
18 | Move down. |
19 | Decision group. |
20 | Add a decision. |
21 | Remove a decision. |
22 | Duplicate a decision. |
Standard Actions
Standard actions allow you to execute an action when an event is triggered.
Example- Project to welcome candidates to the course
As an example, implement a Standard action to welcome the users when they enter their name in the course you create.
-
-
Add a text entry box and a text caption from the Text menu.
-
Delete the Submit button which opens up along with the text entry box and add a standard button. This is done so because the button which comes along with the text entry box cannot be hidden from the slide during runtime. Rename the added standard button as Submit.
-
Edit the text caption as Enter your name in the box below and press enter to start the course.
-
Select the text entry box, go to the Properties Inspector, Properties tab, Style section and click the [X] icon against Variable to open the Variable Name dialog box.
-
In the Variable Name dialog box, enter the variable name as Candidate_Name. You are not just creating a variable but also associating the variable with the text entry box by doing this step.
-
Add two text captions to the slide from the Text menu. Make both these captions invisible in the output by using the eye icon left to the caption name under the Properties tab of Properties Inspector.
Rename one of these captions as Welcome to the course,
-
The second text caption added to the slide in the previous step will be used to call the variable Candidate_Name to display the name entered by the user. Click into the text caption to enable the Insert variable [X] button in the Properties Inspector, Properties tab, Character section under Style.
In the Insert Variable dialog box, select the variable Candidate_Name against the Variables drop-down list.
When you do this step, the default text caption changes to $$Candidate_Name$$ to denote that the Candidate_Name variable is called from this text caption.
Opmerking:You can also call the variable by directly changing the text of the caption to the variable name and preceding and succeeding it by $$. But best practice to call the variable is by clicking the [X] icon and opening the Insert Variable dialog box as this allows you to control the maximum length of the variable value to be displayed.
-
Select the text entry box added in step 2, go to Properties Inspector, Properties tab, Actions section, and in the On Success drop-down list, select Execute Advanced Actions.
-
Click the folder icon against the Script drop-down list below On Success to open up the Advanced Actions dialog box. Enter the actions in the image below by clicking into the rows of the dialog box, and enter the Action Name as AdvAction_Show_Name.
-
To view this project in action, run preview.
Conditional Actions
Conditional actions, as the name suggests, are executed only when a condition or set of conditions are met.
Check the Conditional Tab in the Advanced Actions dialog box to set the condition and the corresponding action.
If..else logic
If..else logic is:
- If a condition or set of conditions are met, execute an action.
- Else (if the condition or conditions are not met) execute another action.
As an example, you can set up a conditional action to display a text caption to welcome a candidate if their age is greater than 15, and to display a deny-entry caption otherwise.
While logic
While logic is a conditional loop that evaluates a condition at the beginning of a statement, and continues to loop a set of actions until the condition or set of conditions is true or false.
As an example, you can set a criterion for an eLearning course eligibility that while the candidate is a graduate and their experience is greater than or equal to 5 years, accept the candidate.
Example 1 - Project to share facts about planets in the solar system
This project implements conditional actions to share some interesting information about the planets in our solar system.
-
Open a blank project and add nine content slides. Delete the default title slide.
-
Add three text captions and a text entry box to the first content slide.
- Rename the three text captions as Know your planets, Enter the name of a planet below to get some interesting information, and Check the spelling and try again! respectively.
- Make the caption Check the spelling/case and try again! invisible during runtime by using the eye icon next to its name under the Properties tab of Properties Inspector.
- Select the text entry box, go to Properties Inspector, Properties tab, Style section, and deselect Retain Text.
- Also, click More Options below Retain Text and select Allow All.
- Click the [X] icon under Variable and create a variable named Input_Planet for readability.
- Also, add the image of the solar system to this slide given to you.
- Resize and reorient the elements. You can also format the text captions for visual appeal (see the image below).
-
In the second slide, add a rectangle from the Shapes menu, a text caption from the Text menu, and a button from the Interactions menu.
- Change the opacity of the rectangle to 0%. To change it, go to the Properties Inspector, Properties tab, Style section, Fill.
- Enlarge the rectangle into a border for the slide.
- Move the button to the upper-right corner of the border. This button will act as the close button.
- Change the caption of the button to X to denote the closing symbol. To change it, go to the Properties Inspector, Properties tab, Style section, Caption.
- Also, for the button, in the Actions section in the Properties tab, select On Success as Jump to slide and the Slide as 1 slide 1.
- Add the image of Mercury given to you, to the slide.
- Add the facts about Mercury from the Planets.docx document given to you, into the text caption.
- Rename the image as Image_Mercury, text caption as Text_Mercury, and the rectangle border as Border_Mercury for readability.
- Align all the elements you added to the slide. (See the image below).
- Select this slide in the Filmstrip and in the Properties Inspector, Properties tab, Actions section, choose On Enter as Hide Playbar.
-
Repeat step 3 to add a planet each to the rest of the slides. In the sample project given to you, the planets have been added in sequence according to their distance from the sun. Make sure to rename the elements added to the slide appropriately.
-
Create a condition that if the users enter a planet name, they are taken to the slide which contains that planet's information. And if they enter the spelling incorrectly or doesn't start the name in uppercase, an error message is displayed.
To achieve this logic, an Advanced Action has to be set up for the text entry box added to the first slide.
- Go to the first slide and select the text entry box.
- In the Properties Inspector, Properties tab, Actions section, select On Success as Execute Advanced Actions.
- Against the Script drop-down below Execute Advanced Actions, click the folder icon. The Advanced Actions dialog box opens up.
- In the Advanced Actions dialog box, check the Conditional Tab.
- Enter the IF condition, and the corresponding action. In this case, if the user enters Mercury, jump to the second slide. (See the first image below in this step)
- Similarly, set up the condition and the corresponding actions for the other planets in separate tabs Untitled-1 to Untitled-8. By default only three tabs are present; so manually add more tabs.
- In the ninth tab, enter the condition to display the error message. The logic is that if none of the planet names are entered correctly, or if the name doesn't start in uppercase, an error has to be displayed. Also add a second action in this tab to jump to slide 1; this automatically refreshes the Submit button during runtime. (See the second image below in this step).
-
Select the first slide in the Filmstrip, go to Properties Inspector, Properties tab, Actions section, and select On Enter as Hide. In the Hide drop-down, select the text caption which contains the error message. This removes the error message when the user enters the first slide for exploring more planets, after a sequence of bad and successful attempts.
-
To see the project in runtime, preview the project.
Example 2
In this example, when you click a button an object disappears, and reappears when you click the button again.
Perform the following steps:
-
Declare a variable myVar with value equal to 0.
-
Create an Advanced Action B1 where:
-
If the value of myVar is equal to 0
-
Then hide the object and assign the value of myVar to 1.
-
Else show the object and assign the value of myVar back to 0.
-
Save the action and preview the project. You can see that when you click the button the object disappears, and appears again when you click the button again.
-
Advanced Actions using JavaScript
In this example, when you click a button, an Advanced Action containing a piece of JavaScript code executes producing the desired result.
Launch the Advanced Actions dialog box and assign Execute JavaScript as action and write the following snippet in the Script_Window to get the current frame of the movie:
alert(window.cpAPIInterface.getCurrentFrame());
When you preview the above Advanced Action on a browser, you get the result as follows.
For more information, see Common JavaScript interface of Captivate.
Shared Actions
If you want to use an Advanced Action in other parts of the same project, or in a different project, you can save it as a Shared Action.
For example, as an eLearning author, you have to repeatedly use an Advanced Action to welcome the candidates to the courses you create. Let's save the Advanced Action created in the section Standard Actions as a Shared Action and open it in a new project.
-
Open the project created in the section Standard Actions.
-
Open the Advanced Actions dialog box and open the existing action AdvAction_Show_Name.
-
Save it as a Shared Action by clicking Save As Shared Action button at the bottom of the dialog box. The Save as Shared Action dialog box opens up.
-
In the dialog box, name this Shared Action as SharedAction_Show_Name. You can see that all the elements involved in AdvAction_Show_Name show up under Parameter Values. Enter a description against each parameter to identify its function. Description is important to understand the purpose of these parameters when you use them later. Also give a description to the Shared Action. Save the Action (see the image below).
-
In the Advanced Actions dialog box, click the Export icon in the upper right corner (see the image below). It opens the dialog box for you to save the action as a file on to your device.
-
Open a blank project, go to the Project menu and open Advanced Actions.
-
Click the Import icon in the upper right of the Advanced Actions dialog box. Browse and locate the saved Shared Action file and import it.
-
Repeat steps 1 - 8 of the section Standard Actions and customize the names of the added elements.
-
Select the Text Entry Box and go to the Actions section under Properties tab of Properties Inspector. Select On Success as Execute Shared Action. There is a {P} icon against this option. Click this icon and it opens up the Shared Actions Parameters dialog box.
-
Supply parameter values to the imported parameters. Parameter values to be entered are the elements you added to the new project. By doing so, you are associating the elements in the new project with the Shared Action.
-
To see the Shared Action in runtime, preview the project.
For more information on Advanced Actions, see the article Advanced actions in Adobe Captivate.