Storyline 2: Introduction to Variables

Article Last Updated

This article applies to:

In this tutorial, you'll get a foundational introduction to Articulate Storyline 2 variables. Variables are used to collect and store information—such as a learner's name or numeric value—that you can use anywhere throughout your course to present dynamic content based on that information. Variables are also a great way to add conditional interactivity to your course.

Storyline makes working with variables easy. Without writing a single line of code, you can create and trigger variables.

There are three types of variables: text, numeric, and true/false.

Download these practice files. Watch the video, then follow the steps below to practice working with variables.

Now that you have a good introduction to Storyline variables, try the following practice activities for each type of variable: number, text, and true/false.

Practice Activity: Working with Number Variables

In this exercise, we'll use a variable to count the number of times a user clicks an incorrect answer and then display a feedback message after the third unsuccessful attempt.

  1. Open the 03G_Variables.story file from the practice files and go to slide 1.2 Practice.
  2. Create a new number variable and name it Count3Clicks.
  3. Add a text box to your slide containing a reference to the Count3Clicks. This is helpful for troubleshooting while you're building the slide and can be deleted when you're done. Tip: You can insert a reference by typing the name of the variable surrounded by percent signs (%). For example: %Count3Clicks%
  4. Create a new trigger for the flashlight object that adds 1 to the Count3Clicks variable when it's clicked.
  5. Preview the slide and click the flashlight a few times to see how the variable increases each time.
  6. Copy and paste the trigger you just created for the flashlight to the other two incorrect answers: water1 and radio1.
  7. Preview the slide again and test all three incorrect items to verify that the number variable increases.
  8. Create a trigger that displays the Try Again slide layer when the Count3Clicks variable equals 3.
  9. Now apply what you've learned about triggers and slide layers to add a trigger that hides the Try Again layer when you click the X object (Multiply 1) on that layer.
  10. When the user restarts this interaction to try again, we need to reset the number variable back to 0. Create a trigger that adjusts the Count3Clicks variable back to 0 when the user clicks the X object (Multiply 1). 
  11. Preview the slide to test that everything is working properly.

Practice Activity: Working with Text Variables

In this exercise, you'll use a text variable to dynamically display content based on text entered by the user.

  1. Open the 03G_Variables.story project from the practice files. Go to slide 2.4 Practice.
  2. Insert a text-entry field on the right, just above the Submit button. Format it so it has white text, a white outline, and no fill.
  3. Notice in the Triggers panel that Storyline automatically created a text-entry trigger.
  4. Click Manage project variables in the Triggers panel. When the Variables window opens, double-click the text-entry variable you created above and rename it to YourName.
  5. Next, insert a reference to display whatever name the user enters.
  6. On the next slide, click inside the text box and position your cursor at the end, just before the period.
  7. Insert a Reference to the YourName text variable. Tip: You can also insert reference by typing the name of the variable surrounded by percent signs (%). For example: %YourName%
  8. Preview the scene to see how everything works.

Practice Activity: Working with True/False Variables

In this exercise, you'll use a true/false variable to dynamically display a visited button state on a menu slide based on which sections of the course a user has completed.

  1. Open the 03G_Variables.story project from the practice files. Go to the 3.3 Practice slide.
  2. The first thing we'll do is setup the navigation. Add a trigger to the Go button for Module One that jumps to slide 3.4 Practice when you click it.
  3. Then add a trigger to the back button on the Module 1 slide (3.4 Practice) that jumps back to the main menu slide (3.3 Practice) when you click it.
  4. Preview the scene to test your navigation settings.

Now that the navigation is in place, create a true/false variable to track whether or not the user has completed Module 1.

  1. Create a new true/false variable with a default value of false and name it ModComplete.
  2. To show what is happening with the variable as the learner navigates the slides, add a text box to display the current value of the variable on the menu slide (3.3 Practice).
  3. Preview this slide and note that the value of our variable is set to false.

Next, you need to add a trigger to adjust the ModComplete variable to true when learners click the back button in Module 1. (Reaching this slide means that you've completed Module 1.)

  1. Create a trigger that adjusts the ModComplete variable to equal True when the Back button is clicked.
  2. Preview the scene to see if everything is working correctly.
  3. Tip: The order of triggers is important. Storyline executes triggers in the order they appear in the Triggers panel. If your variable isn't adjusting as you'd expect, try reordering the triggers, using the Up and Down arrows in the Triggers panel so the Jump to slide trigger comes after the Adjust variable trigger.
  4. Preview the scene to check that your triggers are working and your variable is changing as expected.

The final step is adding a trigger on the main menu slide that displays the correct Module 1 button state based on whether or not Module 1 has been completed.

  1. On the main menu slide (3.3 Practice), create a trigger that changes the state of the module 1 button (Mod 1) to Complete when the timeline of the slide starts.—but only if a learner has completed module 1 and therefore the true/false variable has been set to true.
  2. Preview the scene to see how everything works.

As you can see, variables are powerful and flexible, and they're great for adding any type of conditional interactivity to your course. The best part is that anyone can use them, because you don't need to know anything about coding. Imagine all the ways you can use variables in your e-learning projects.

In the next tutorial, you'll build on what you've learned by creating a great slider interaction.