How do you flip-flop a variable from true to false when a user clicks a
button? This is what I've used below, but it only changes the variable
once and then does nothing. HELP!
I don't have SL handy. But is your variable a True/False variable or a text var. Looking at your conditions, the cases of the operators are different. false vs False and true vs True. Not sure if this is a behavior of the condition. If it's a text var, just change the cases to match.
It's a True/False var. The trigger wizard changes the case like that, which I thought was strange too. I've tried with the operator "equal to (ignore case) but it behaves the same.
No go. I think what's happening, the trigger chain executes everything in the chain in order. So it senses the opposite, changes it then senses the opposite and changes it again. Might try this based on a toggle state rather than a set of triggers and variables.
An object that isn't in a group automatically has a toggle behavior. Click once, selected. Click again, not selected. If you've already wired up your variables you should be able to drive your switch condition based on the state of the object.
Steve's, solution is good. I looked at this earlier and it gave me a headache. Like Steve says the triggers fire consecutively, states is the only way to elegantly catch this.
Yep, have to change the variable based on the state of the button. Seems convoluted. Wish there was a "stop processing further triggers" option on the object triggers actions. I've already submitted 2 feature requests, so I'll let that one go for now.
For those wondering about the answer, the picture below shows the triggers needed to have a button change the state of another object using a variable.
What you do is:
Object Triggers on Click: change the state of the object based on the value of the variable.
Change the variable based on the state of the object.
Slide Triggers:
Change the state of the target object when the variable changes
Ackbasswards a little bit, but that's what you have to do, or maybe you don't? any suggestions?
If you want to preserve your sanity by not trying to implement the "toggle" trigger, you can do it without states by adding one more variable and a couple triggers. Here's the story
Thanks all. Was rather stuck till I came across this. (Had an intro layer on my slide that played, then hid itself to play a video on the base layer. But the video wouldn't autoplay, so I had a variable, 'IntroLayerPlayed' set at false when the layer timeline started and switching to true when it ended, and a trigger to play the video when the variable changed. But as I could only set the trigger by 'variable changed', not 'variable = true', if I clicked away and back onto that slide, changing the variable to 'false' again would play the video with the layer still showing above it. I had no idea about toggling [hope this is in the tutorials!]). Now it all works perfectly!
Where did that come from, 9 months and many sleepless nights and I have never seen that one
I bet you photshopped that one
Best topic ever here. I laught a lot with this I spend almost one day looking for this option until find the NOT assignment :DAnd for me is normal use variable = !variable in AS3. I don't know why I take too much time to realize that on SL :Dhahahahahha really cool :D
28 Replies
I don't have SL handy. But is your variable a True/False variable or a text var. Looking at your conditions, the cases of the operators are different. false vs False and true vs True. Not sure if this is a behavior of the condition. If it's a text var, just change the cases to match.
It's a True/False var. The trigger wizard changes the case like that, which I thought was strange too. I've tried with the operator "equal to (ignore case) but it behaves the same.
This seems funny.. but try this. Set equal to false when user clicks if bright is NOT equal to false. See if that makes a difference.
No go. I think what's happening, the trigger chain executes everything in the chain in order. So it senses the opposite, changes it then senses the opposite and changes it again. Might try this based on a toggle state rather than a set of triggers and variables.
An object that isn't in a group automatically has a toggle behavior. Click once, selected. Click again, not selected. If you've already wired up your variables you should be able to drive your switch condition based on the state of the object.
Make sure you add the state selected to your object
I've got this working using states.
Like this:
http://dl.dropbox.com/u/19820702/toggleBright.story
Steve's, solution is good. I looked at this earlier and it gave me a headache. Like Steve says the triggers fire consecutively, states is the only way to elegantly catch this.
Yep, have to change the variable based on the state of the button. Seems convoluted. Wish there was a "stop processing further triggers" option on the object triggers actions. I've already submitted 2 feature requests, so I'll let that one go for now.
For those wondering about the answer, the picture below shows the triggers needed to have a button change the state of another object using a variable.
What you do is:
Object Triggers on Click: change the state of the object based on the value of the variable.
Change the variable based on the state of the object.
Slide Triggers:
Change the state of the target object when the variable changes
Ackbasswards a little bit, but that's what you have to do, or maybe you don't? any suggestions?
How 'bout just toggling it:
Oops, didn't see your post before the one I did above Steve Ironman.
Yep, your solution is way more elegant and combines two steps into one and gets rid of my convoluted logic. Thanks.
There's also a far less elegant way but may be easier for some folks to comprehend.
Use two buttons instead. Call them Button 1 and Button 2. Button 2 is initially hidden. Button 2 is on top of Button 1.
Then add triggers to do the following:
Again, not as elegant, but it works.
Where did that come from, 9 months and many sleepless nights and I have never seen that one
I bet you photshopped that one
Haha. Yes. That solution (just toggle it) wins.
Steve's solution is a good one.
If you want to preserve your sanity by not trying to implement the "toggle" trigger, you can do it without states by adding one more variable and a couple triggers. Here's the story
thanks John this the sort of thing I will wake in the middle of the night with a solution
this might give a good night sleep
So the toggle is a photoshop? I can't find it anywhere, don't laugh....
Under Operator, set the dropdown to = NOT Assignment. That changes the representation to toggled. I forgot that was there
Wow! Wish I 'd realized that sooner too, I've done some convoluted toggling myself, LOL
Shoot, that was easy. 1 trigger just replaced at least 2 or 4. Much easier, can't see a downside.
TIme to edit the SL tutorials?
Thanks all. Was rather stuck till I came across this. (Had an intro layer on my slide that played, then hid itself to play a video on the base layer. But the video wouldn't autoplay, so I had a variable, 'IntroLayerPlayed' set at false when the layer timeline started and switching to true when it ended, and a trigger to play the video when the variable changed. But as I could only set the trigger by 'variable changed', not 'variable = true', if I clicked away and back onto that slide, changing the variable to 'false' again would play the video with the layer still showing above it. I had no idea about toggling [hope this is in the tutorials!]). Now it all works perfectly!
Thank you!
(Convoluted explanation...but you get my point...)
You folks and this forum are wonderful! If I need help I can always get it here!
I've just made very many strange noises reading this thread and nearly wet myself when I realised how f***ing simple it is to implement a toggle!
I need a lie down!
Might be the post of the day Glenn! Made me laugh :) Glad you were able to get some assistance in this thread.
This discussion is closed. You can start a new discussion or contact Articulate Support.