Hey guys,
Need a little help. I am trying to figure out how to use or (re-use buttons). I have a button to fire a script. eg I have a sketch and when you press the button it runs around the playfield.
I want to be able to click the button a second time to stop the script.
I have tried many things but just cannot quite get there. Any suggestions?? Thanks
Regards
Kelly
Hi Kelly,
Need a little help. I am trying to figure out how to use or (re-use buttons). I have a button to fire a script. eg I have a sketch and when you press the button it runs around the playfield.
I want to be able to click the button a second time to stop the script.
I have tried many things but just cannot quite get there. Any suggestions?? Thanks
You could ask the label of your button, if it says: "run" then run the sketch _and_ change the label to "stop", and if it says "stop" vice versa.
"What makes sense to the user, often makes sense to the developer too..." ;-)
Cheers,
Markus
Hi Kelly,
A possible solution might be to use two scripts: the first on does the spinning, the second one is reponsible of start and stop of the spinning and uses a Boolean variable of the figure.
See the attached screenshot
Markus ----------------------------------------------- Markus Schlager m.slg(at)gmx.de
Hey guys,
The answer seems so obvious now! That's always the way I guess.
Thank you for all your suggestions, it's most appreciated.
Regards Kelly.
PS Markus I decided to go with your suggestion, thanks!
On 24/02/06, Markus Schlager m.slg@gmx.de wrote:
Hi Kelly,
A possible solution might be to use two scripts: the first on does the spinning, the second one is reponsible of start and stop of the spinning and uses a Boolean variable of the figure.
See the attached screenshot
Markus
Markus Schlager m.slg(at)gmx.de
Hi Kelly,
This works for me. Make a new variable by clicking the sketch's (v) button (right next to its name in the Viewer flap for the the sketch). Give the field a name, like motionToggle. Now make a script with a test. For the "test" part of the test structure, drag the new variable out of the flap and into the "test". Change the condition to "= true". Put your sketch motion in the "Yes" part of the test. Check that the motionToggle variabe works controling the motion by toggling it from true to false in the flap.
Now on you button click script add another test. If motionToggle is "true" assign it "false". If motionToggle is "fales" assign it "true".
The attached gifs are similar to what you need, but not exactly .
Let us know if you need more help.
Cheers, Darius
You can also toggle the button's color or text on click and then have the sketch's motion script test the button's color or text.
Cheers, Darius
On 2/24/06, Darius Clarke socinian@gmail.com wrote:
Hi Kelly,
This works for me. Make a new variable by clicking the sketch's (v) button (right next to its name in the Viewer flap for the the sketch). Give the field a name, like motionToggle. Now make a script with a test. For the "test" part of the test structure, drag the new variable out of the flap and into the "test". Change the condition to "= true". Put your sketch motion in the "Yes" part of the test.
Check that the motionToggle variabe works controling the motion by toggling it from true to false in the flap.
Now on you button click script add another test. If motionToggle is "true" assign it "false". If motionToggle is "fales" assign it "true".
The attached gifs are similar to what you need, but not exactly .
Let us know if you need more help.
Cheers, Darius
squeakland@lists.squeakfoundation.org