Hi, I'm a newbie, just off the 2011 Summer Academy.
I've been following the BYU tutorials, and have got to a point where I want to create a 2-state button, e.g. Record/Stop recording, where the same button will switch dynamically to its opposite function, e.g. if it's recording, it will show Stop recording, and vice versa.
I'm thinking it must be a very commonly used routine, (and I don't want to waste time needlessly re-inventing existing wheels) but I can't seem to find a standard routine for this anywhere online. Anyone got the code for this, or is it something I should work it out for myself?
Cheers
2-state button
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 75
- Joined: Mon May 09, 2011 3:01 pm
- Contact:
2-state button
Geoff Taylor


Re: 2-state button
Hi gjtaylor99,
you will need to check and set "the label" of the button like this:
You could also change the ICON accordingly if necessary.
You get the picture.
Best
Klaus
you will need to check and set "the label" of the button like this:
Code: Select all
on mouseup
if the label of me = "Start" then
set the label of me to "Stop"
### start your recording here...
else
set the label of me to "Start"
## stop recording here and now
end if
end mouseup
You get the picture.
Best
Klaus
-
- Posts: 75
- Joined: Mon May 09, 2011 3:01 pm
- Contact:
Re: 2-state button
Wow, I suspected it was something like that, but then went off into unnecessary complications. Your solution is so clean and simple! Thanks a lot.Klaus wrote:You get the picture.Code: Select all
on mouseup if the label of me = "Start" then set the label of me to "Stop" ### start your recording here... else set the label of me to "Start" ## stop recording here and now end if end mouseup
Geoff
Geoff Taylor


Re: 2-state button
Keep asking.
LC is built in such a way so that many solutions are just that compact and beautiful. It is the structure of the language that makes it so.
Keep asking.
Craig Newman
LC is built in such a way so that many solutions are just that compact and beautiful. It is the structure of the language that makes it so.
Keep asking.
Craig Newman