Change States When Object is Clicked on Multiple Times

Jul 02, 2014

Is there a way to change the state of the same object multiple times, simply by clicking on the object? For example, I want to change a shape from red to blue to green by clicking on the shape. This should be continuous. So as long as I keep clicking the colors will change in order.  

I am guessing I have to use variables?

Thanks

John

19 Replies
Rebecca Fleisch Cordeiro

Hi John and Michael,

I thought this might be doable without variables, and turns out it is (at least, I think it's working as you'd described, John). Either way is correct, of course...but figured I'd throw it up here.

The particulars:

Initial state (normal state) is blue.

Then I created a state for red, green, orange, and blue

You'll see how the triggers work if you look at the triggers panel...trigger order is important.

Please shout out with any questions.

Rebecca Fleisch Cordeiro

Tx, Mereym!

To tell the truth, John, I fiddled a little. I had them all but one.

I knew that, according to Articulate support,

If there are multiple triggers on the same object that are triggered by the same action (such as "on click"), the triggers execute in the same order in which they appear in the Triggers panel (top to bottom).

And that SL "looks" down the list and keeps going until it finds a trigger that it can use (you can tell by my description that I'm not a programmer ).

So a sort of "reverse order" seemed to work here...

George Tuft

Hi all...

I have a similar issue.

I'm trying to change the state of a character back and forth upon clicking the character.
I've uploaded a sample.

I've tried re-ordering my triggers. One order allows me to change from normal to angry, but not back to Normal. The other order does nothing. :(

I downloaded Rebecca's file, and what I've built looks similar...but I can't seem to get the states to bounce back and forth. 

Can someone have a look and suggest a change?

Thanks!

-gt

Walt Hamilton

If you use only current state to determine whether to change or not, the character will always change to the last trigger's state.

You need an independent, outside, impartial observer (like Wendy's variable) to declare what state to change.

If you change based on the current state, the state will change twice. Notice that the variable only changes once, without the need for a condition, so it is reliable.

George Tuft

Thanks Wendy...I had been just about to do exactly that!

Great minds... :)

So, I'm still confused as to why Rebecca's file works, but mine doesn't.
She's using no variables, and only referring to the actual state of the object.

Is it because she's got a NORMAL state that matches the BLUE state, and that's allowing for the progression somehow?

 

 

Wendy Farmer

Hi George

I edited Beccy's file to show the name on the state - as you can see it never touches the 'BLUE' state.

I also added in a slide with just two states and it behaves the same as your's changes state once but not again.

Hence the use of variable.

Walt Hamilton

George,

What an eye-opener this has been for me.  Your Character never changed to calm because of the order of the triggers. When the first trigger found him angry, it turned him to calm. Then the second trigger found him calm and turned him back to angry. (Changing the order of the triggers would make him always calm and never angry, for the same reasons.) I always thought that only the last state persisted, but looking at Rebecca's file, I realize that in reality, only the first state is never used. Her blue state is never seen, because her last trigger always turns blue to normal. Since they are identical, nobody notices.

I did the same with your sample. I duplicated the calm state, and called it New State, set up the triggers, and now you can click him and he toggles between calm and angry. The difference is that there are three states, and the one associated with the first trigger is never used, so he looks to be switching between two states. (I did add a little color to the New State to make it obvious what is happening.)

You may need to change the order of the triggers, and maybe duplicate the angry state. Depending on his initial state, it may take two clicks to change him the first time.