Your browser (Internet Explorer 7 or lower) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

X

Introduction to Variables

Ah, variables.

Geeks love ‘em.  The rest of us struggle to “get” them.  But beware, for once you come to understand them, there’s no going back.

Now the reality is that even though you may not realize it, you have likely interacted with and even altered variables before.  For example, let’s say you create a quiz in your favorite eLearning program (such as Quizmaker) and you’ve told the program that each question is worth 5 points.

As the learner progresses through the quiz, the score is increasing by 5 points each time the learner correctly answers a question.  The score changes from 5 to 10 to 15 and so on with each correctly answered question.

Well the score is a variable (a value that may change).  The variable (score) starts off at ”0″ and changes as the quiz progresses.  You might think of a variable as a little behind the scenes “assistant” helping you keep track of things in your course.  You give the “assistant” some instructions and then they go off and do their work in the background.  In the case of the Quiz we’ve just mentioned, your little “assistant” has instructions to keep track of the user’s answers and add 5 points to their score every time the user answers correctly.  And remember, you told your “assistant” how many points to add, so even though you didn’t realize it, you were interacting with a variable.

The exciting thing with Storyline is now you get to see behind the scenes.  In fact, you get to create your own little assistants (variables) and put them to work in many varied and different ways.

While this may make sense, the challenge for many of us is the application. What are some tasks that I might have my little assistants do?  What information might I have them track?   Great questions! So let’s take a look at a simple example to get you started.

GOAL:

Suppose that somewhere in your Storyline project, you want a hidden object to appear only after a user has clicked a certain button 10 times.

HOW TO:

Easy!  You turn to your loyal assistant and say “Assistant, please do the following: when the learner has clicked button X ten times: please change the state of object Y from hidden to normal”.  And your assistant amiably trots off behind the scenes and starts tracking button clicks.  Okay, so it doesn’t work quite that smoothly. So here’s how we do it in Storyline (now mind you, this may seem like a lot of steps, but once you understand the process, creating these will go quite quickly).  Okay, let’s open up Storyline and start with a blank canvas.

Insert an illustrated character onto your canvas and set the starting state to hidden (you’ll notice that “Bob” is greyed out).

Insert a button onto your canvas.

 

Create a number variable by clicking the X box in the trigger panel.

Once the variable pane opens, click the new variable button, name your variable (I named mine “clicks”), choose “Number” for the variable type, and leave the starting value at zero. Click Okay.

Sweet!  You’ve just created a new little “assistant”.  Of course, you don’t see the “assistant” because it’s hiding there in the background.  But if you click on the insert variable X button again, you’ll see it waiting for you in the variable pane. Now, let’s continue.  We must create some instructions for our little assistant!  Our next step is to tell our little assistant to pay attention to button clicks.  We’ll do this by adding a Trigger to the button on our canvas.

Select the button on the screen and add a trigger (by either clicking the trigger lightening bolt in the ribbon, or by clicking “Add trigger” underneath the button in the trigger pane).

We’re going to tell our assistant to increase by ’1′ every time the button is clicked.  We tell it to perform this by: Action (Adjust Variable).  Which Variable? (Clicks).  What is the Operator? (+Add).  Add what Value?  (Value of 1). When should our little assistant add this value? When the (User Clicks).

So we’ve just told the variable to increase by 1 every time the button is clicked. But now we also have to tell our little assistant to change “Bob” to normal once the button is clicked 10 times. To do so, we’re going to add another Trigger.

Add a new Trigger by either clicking on the Trigger button in the ribbon, or the Trigger Icon in the Trigger Panel.

Now we’re going to program our trigger.  We tell it to perform this Action (Change state of).  Change state On What Object? (Character Bob).  Change Bob To what state? (Normal).  When should I change Bob? When the (Variable changes). When what Variable changes? (Clicks)

So you’ve just told your assistant to change Bob to Normal when the variable called “Clicks” changes, but your little assistant says “when ‘clicks’ changes to what value?”   Under what conditions exactly, should I change Bob to normal? Good question little assistant!  I want you to change Bob to normal when ‘Clicks’ is equal to or greater than 10.

So we’ve got one more really cool step left in the process. It’s called setting up a trigger condition.  We’re going to tell the assistant exactly when to change the state of Bob to normal.

In your trigger wizard pane, you’ll notice “Show Conditions”.  Click on that and we’ll be off and running.

Click the plus sign in the lower right to add a condition.

We’re going to tell our little assistant to change Bob to Normal If (Clicks) is Operator (>=Greater than or equal to) a Type (Value) of Value (10).

Okay, let’s test it out.  Preview your slide and click the button 10 times.  Voila!  Bob appears on the 10th click.  Your little assistant was there in the background tracking your clicks on the button and changed Bob to normal once the variable reached ’10′.  Now, this may seem like a lot of steps, but once your familiarity with the Storyline interface grows, you’ll find that it’s a pretty quick process.

So that’s one example of creating an assistant to keep track of things behind the scenes and give your course some fun capability.  Stay tuned for further posts here at Storyline Authors as we’ll be sharing other ways that these variables come in really handy!

BONUS!

Want to “see” your little assistant at work?   On your canvas, add a text box and type %your variable name%.  So in my case, I’d type %Clicks%. Yes, you type the percentage signs and the name of your variable.  This allows you to bring your variable from behind the scenes and display it on the slide.  Oh my…what possibilities does that open up?

 

Comments

Bret Deardorff
Reply

Nice example of variables and triggers. Now I just need to come up with a fun way to use these!

sovanno
Reply

Can I have one example for this “Introduction to Variables” to .story
because i am not speack very well english. I am speack only french.

thank you

Leave a comment

name

email (not published)

website