Download Free Adobe Captivate content to experience all new features of our 2017 release

While Loop in Captivate 2017 Advanced Actions

To follow along and try it yourself, download the CPTX from: WhileLoop and open it in Captivate 2017

A “while” loop can be used to repeat a set of actions a certain number of times, or till a condition is met. It can also be used to repeat some actions infinitely.

Let us use an example to demonstrate While loop in Captivate 2017.

  1. Create a new slide and insert some objects as below. You may use your own assets or use the Arrow and Circle shapes from the Smart shapes menu.

circle

 

  1. Each of the Circle shapes has a custom state added to it as shown below:

1_2

 

You can add states to the circles by selecting the circle, going to the Properties Inspector and adding a new State to it:

3_3

Let this new state be named “NewState1

 

 

  1. Add a button to the slide and set its action to “Execute Advanced Action” and add a Script to execute a While loop.

gr

  1. Create a new advanced action, and check the “Conditional Action” checkbox. You will see an “If’ in the condition section. Click the dropdown next to it and change it to While.

4_$

  1. The script should have a structure as below. (1==1) condition :

55

 

Below is the logic:

While (1 == 1) {

Change State of ‘Active Circle’ to NewState1

Apply Flicker Effect on ‘Active Circle’

Change Last Active State back to Normal

}

 

What we are essentially doing here is, using a (1 is equal to 1) condition to simulate the loop running infinite number of times. The actions in this loop will keep on getting executed while 1 equals 1, i.e. forever. We do three things on repeat:

  1. Change the state of the last active circle back to its normal state
  2. Change the next active circle to its Active state
  3. Apply an effect on the next active circle to make the transition look good

These three actions will be repeatedly executed every 1 second.

Note: While loop has an inbuilt Delay of 1 second. This means that, all actions executed within the loop are looped with a delay of 1 second, per loop. Adding more Delay statements will be exclusive of the inbuilt 1 second delay.

  1. Now your slide may look something like this:

 gerg

  1. Preview this slide and click the button to see the While loop in action.

A similar example is on the first slide. A while loop is used to loop between the states of the top-right images infinitely. The OnEnter action for that slide contains this While loop.

Leave a reply

Related