Variables and conditional actions

Variables in Captivate

What are variables

Variables are entities whose values are subject to 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.

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().

Types of variables in Adobe Captivate

SYSTEM VARIABLES

System variables are pre-defined variables in Captivate.

For example,

  • Date.DateDDMMYY is a system variable that returns the date in dd/mm/yyyy format.
  • Quiz.Score returns the number of points that are scored in a project.

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.

Data types

You can create a variable of the following data types:

  • Number: The variable stores value of type numeric. For example, 5,-25,3.14, and so on.
  • True/False: The variable stores value of type Boolean. For example, true or false.
  • String: The variable stores value of type character. For example, Hello World, Captivate, C3PO, and so on.

Create a user variable

You can create user variables in your Captivate project by choosing Variables in the Project Properties panel. This opens up the Variables dialog box. To create a user variable, click +. Then specify the name of the variables, its type, and the value.

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.

Create a variable
Create a variable

Variable naming conventions

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 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.

Edit a user variable

After creating a variable, if you want to modify the variable, such as the name, value, or the description, click the one you'd like to change, and modify its contents.

Edit a variable
Edit a variable

Delete a user variable

To delete a user variable, in the Variable dialog, select the variable that you want to delete. Click the Delete button.

Delete a variable
Delete a variable

Copy and paste a user variable

To Copy and Paste a variable, select the variable, click Copy, and then click Paste. You can also copy and paste multiple variables at once.

Search a user variable

To search a variable, click the Search button, and type the name of the variable or part of the variable. Any partial match will also return the variables, both user and system.

Search a variable
Search a variable

Use a variable in a project

After you create a variable, now it is time to use that variable in a project. Follow the below to insert a variable in a project.

  1. In the project, you'll insert a variable on the stage. When you'll preview the project, the value will display.

    In the Captivate project, insert a text box, as shown below.

    Set up the project
    Set up the project

  2. In the text box, insert the variable that you had created. Type $$, select the variable from the list, and then enclose the variable with $$.

    Select the variable
    Select the variable

  3. Preview the project. You will see that the value of the variable now displays.

Actions on variables

Assign a variable

You can assign another value to variable, which already had a value assiged to. In addition to a value, you can also assign the value of another variable, an expression, or content of an element.

Assign value of a variable

Insert an object and a text box on the stage. Insert a variable in the text box and make the object clickable. When you'll click the object, the value in the text box will change to the newly assigned value.

Assign value
Assign value

Adjust value of a variable

Insert an object and a text box on the stage. Insert a variable in the text box and make the object clickable. When you'll click the object, the value in the text box will change to the newly modified value.

Adjust value
Adjust value

Toggle value of a variable

Insert an object and a text box on the stage. Insert a Boolean variable in the text box and make the object clickable. When you'll click the object, the value in the text box will toggle to either True or False.

Toggle value
Toggle value

Conditional actions in Captivate

What are conditional actions

Conditional actions, as the name suggests, are actions that are contingent upon a condition or a set of conditions. In other words, IF a certain condition exists, (or does not exist), THEN perform an action or a sequence of actions, or WHILE a condition exists or does not exist, then perform some actions. Conditional actions exist in our day to day lives, such as:

  • If I turn the ignition ON, the car starts.
  • If I flip the switch on the jukebox, the music plays.

When designing eLearning content using conditional actions, you pretty much follow the same logic. For example,

  • IF a user selects option A, THEN mark the answer incorrect AND restart the quiz.
  • IF a user selects option B, THEN add 10 points.

Types of conditional actions

Captivate supports the following types of conditional actions:

  • IF-ELSE: The IF/ELSE condition executes an action or actions if a specified condition is True. If the condition is False, the Else action is executed.
  • While: The WHILE condition executes an action or actions as long as the specified condition is True.

Create a conditional action

Here, you'll create a conditional action where upon clicking an object, a condition is evaluated (for example, value of a variable is greater than 100), and based on the condition, an action is performed (for example, hide an object or apply object effects.).

In the demo below, when you click the button, depending upon a condition, the image will be displayed (the image is hidden on the stage).

Condition

Define two variables var_num_one and var_num_two. When defining the condition, if the value of var_num_one is less than var_num_two, then execute the action, which, in this case, is displaying the image.

The stage

Set the stage
Set the stage

Variables

  • var_num_one=100
  • var_num_two=200
  1. Select the object and click Interactions. Add an interaction for the object. Click the interaction Click/Tap.

    Click/Tap interaction
    Click/Tap interaction

  2. Click Conditions.

    Conditions panel
    Conditions panel

  3. In this step, you'll perform the following:

    • Choose the IF/ELSE condition type.
    • Click the button labeled Variable.
    Variable or value comparison
    Variable or value comparison

  4. Choose the two variables. You'll compare the values of the two variables and depending on the condition, execute the action.

    Set condition
    Set condition

  5. Define the condition.

    Define the condition
    Define the condition

    Save the changes.

  6. Now, you'll define the action based upon the condition assuming that the condition executed successfully. You'll display the image that was initially hidden on the stage. Click the action Show and choose the image, as shown below: 

    Set the action
    Set the action

    Click Next and save the interaction.

Upon previewing the project, if you click the object, the image displays because the condition was true. The entire workflow is represented in the gif below.

Conditional action workflow
Conditional action workflow

Copy and paste a condition

To copy a condition, perform the steps below:

  1. Click options in the Conditions panel.
  2. Click Copy.
  3. Similarly, to paste the condition, click Paste.

After you paste the condition, you can see that a copy of the condition has been created.

Condition options
Condition options

Copied condition
Copied condition

Delete a condition

To delete a conditional action, click the options menu of the action, and click Delete.

Delete a conditional action
Delete a conditional action

Edit a condition

To edit a conditional action, hover on the the action, and click Edit.

Edit a conditional action
Edit a conditional action

Disable and enable a condition

To disable and enable a conditional action, click the options menu of the action, and click Disable or Enable.

Disable a conditional action
Disable a conditional action

Enable the conditional action
Enable the conditional action

Triggers

Adobe Captivate is event driven. In other words, whatever a learner sees on the screen at run time is the result of changes that occur in the application. When an event happens, for example, a learner clicks an object, an object may change its shape or gets hidden/displayed. This change in the object is triggered by the event. Captivate, based on the event, evaluates a condition or a set of conditions, and executes an action.

Captivate supports the following triggers:

  • Standard state: If a standard state (hover state, down state, visited state, and so on) is selected, then perform some actions.
  • Custom states: if a custom state is selected, then perform some actions.
  • Variable: Compare a variable with a value or another value. Based on the return value, perform some actions.
  • Content of element: Compare a value with that of another object. Then perform some actions.

In the example below, you'll configure a condition based on custom states.

  1. On the stage, add a button and an image. For the image, add two states, Light and Dark.

    Set image states
    Set image states

  2. On the button, set a Click/Tap trigger, and assign the action, Set state. Set the target state of the image to Dark.

    Set target state
    Set target state

    Click Done.

  3. Now insert another object, a second button, which when clicked changes the state of the object if the object has been viewed previously.

  4. On the second object, add a Click/Tap trigger, and add the condition Custom States

    • Slide objects tab: All objects with custom states in the current slide are listed.
    • Other objects: All objects with custom states in the project are listed.

    Choose the image and then choose the required state.

    Choose ths custom state
    Choose ths custom state

  5. After you choose the state, choose the option All Selected from the Visit drop-down.

    Selected state
    Selected state

    Click Next.

  6. After you've selected the option, set the condition of the state as Viewed. Choose the option Viewed. If you choose this option, the image will change state only after a previous state has been viewed.

    State viewed
    State viewed

  7. After you've specified the condition as a state being viewed, you must set the action. In the Action panel, select the required action. For example, you can set it to Go to Next Slide.

 Adobe

Get help faster and easier

New user?