Toggle 3 states using triggers/variables

May 03, 2018

Hi, I have an object with 3 states. There is a button which, when clicked, should toggle through the 3 states.

Click first time - change to state S1
Click again - change to state S2
Click again - change to state S3
Click again - change to state S1
Click again - change to state S2
...and so on.

Is this possible?

4 Replies
Crystal Horn

Hi Lauren!  Triggers with conditions will be your friend in this scenario.  Will your object be initially set to the first state (i.e. the Normal state), or should it only start changing once you click your button?

You can add conditions to your trigger so that they read like this:  Change state of object to State 1 when user clicks on button IF the state of object is normal, OR if the state of object is State 3.  

Then, change the state of object to State 2 when user clicks button IF the state of object is State 1....and so on.

Let us know how it works out!  If you get stuck, feel free to attach your file here for folks to see.

Russell Killips

Hello Lauren,

This should work for you. I created a numeric variable defaulted to 1.

When you click the up button, it adds 1 to the variable. If the variable equals 4 it is set to 1.

When you click the down button, it subtracts 1 from the variable. If the variable equals 0 it is set to 3.

Then there are triggers that change the state of your rectangle when the variable changes.

This discussion is closed. You can start a new discussion or contact Articulate Support.