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.
- Open the 03G_Variables.story file from the practice files and go to slide 1.2 Practice.
- Create a new number variable and name it Count3Clicks.
- 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%
- Create a new trigger for the flashlight object that adds 1 to the Count3Clicks variable when it's clicked.
Preview the slide and click the flashlight a few times to see how the variable increases each time.
- Copy and paste the trigger you just created for the flashlight to the other two incorrect answers: water1 and radio1.
Preview the slide again and test all three incorrect items to verify that the number variable increases.
- Create a trigger that displays the Try Again slide layer when the Count3Clicks variable equals 3.
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.
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).
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.
- Open the 03G_Variables.story project from the practice files. Go to slide 2.4 Practice.
- 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.
- Notice in the Triggers panel that Storyline automatically created a text-entry trigger.
- 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.
- Next, insert a reference to display whatever name the user enters.
On the next slide, click inside the text box and position your cursor at the end, just before the period.
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%
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.
- Open the 03G_Variables.story project from the practice files. Go to the 3.3 Practice slide.
- 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.
- 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.
- 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.
Create a new true/false variable with a default value of false and name it ModComplete.
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).
- 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.)
- Create a trigger that adjusts the ModComplete variable to equal True when the Back button is clicked.
Preview the scene to see if everything is working correctly.
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.
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.
- 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.
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.