A graphic that change the color all time
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
A graphic that change the color all time
I know it must be a silly question, but I can't find how to do it in a simple way...
I want that a graphic change the color all time, like a button, how I can do that?
Thank so much!
I want that a graphic change the color all time, like a button, how I can do that?
Thank so much!
English is not my mother tongue
Re: A graphic that change the color all time
HI Aha,
1. welcome to the forum!
2. change color all the time like a button?
Automatically every couple of seconds? When you click it?
Sorry don't get it
Best
Klaus
P.S.
Wil move this thread to the "Beginner" section, HINT, HINT!
1. welcome to the forum!

2. change color all the time like a button?
Automatically every couple of seconds? When you click it?
Sorry don't get it

Best
Klaus
P.S.
Wil move this thread to the "Beginner" section, HINT, HINT!

Re: A graphic that change the color all time
Thanks Klaus,
Sorry my english is not as good it should
I have a tabular graphic that increase over time, I want that when it reach to the top it make like a flashing effect, changing color all time.
Thank you!
Sorry my english is not as good it should

I have a tabular graphic that increase over time, I want that when it reach to the top it make like a flashing effect, changing color all time.
Thank you!
English is not my mother tongue
Re: A graphic that change the color all time
So much fun.
Don't tell Simon, but put this in a button script:
Now as payment for this, you must write back and tell me what each line does. Why did I make two handlers? Why the optionKey thing? How are you going to make this sort of thing work in your project?
You will probably have questions, and that is fine. But you are supposed to be learning, not just asking for free code solutions. So do experiment, and do write back with those answers and thoughts.
Craig Newman
Don't tell Simon, but put this in a button script:
Code: Select all
on mouseUp
startFlash
end mouseUp
on startFlash
if the optionKey is down then exit to top
if the backColor of me = "red" then set the backColor of me to "green" else set the backColor of me to "red"
send "startFlash" to me in 30
end startFlash
You will probably have questions, and that is fine. But you are supposed to be learning, not just asking for free code solutions. So do experiment, and do write back with those answers and thoughts.
Craig Newman
Re: A graphic that change the color all time
Is there some fun coding going on without me?? 
Simon

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: A graphic that change the color all time
Uh oh.
Uh, no Simon, er, what makes you think that? Um, how about those Mets?
Craig
Uh, no Simon, er, what makes you think that? Um, how about those Mets?
Craig
Re: A graphic that change the color all time
Haha
Thank so much Craig! that's exactly what I need.
Well, my homework:
The first handler "on mouseUp" tells to LiveCode tht the action will start once someone push the graphic.
The second has a escape in the first line, in case we want it to stop, the second line makes it change the color depending the color it have now, and the last says how fast it got to change.


Thank so much Craig! that's exactly what I need.
Well, my homework:
The first handler "on mouseUp" tells to LiveCode tht the action will start once someone push the graphic.
The second has a escape in the first line, in case we want it to stop, the second line makes it change the color depending the color it have now, and the last says how fast it got to change.

English is not my mother tongue
Re: A graphic that change the color all time
You get an "A".
Why not simply use a single "mouseUp" handler? Any reason to split them? Extra credit: Can you rewrite as a single handler just in case this would work just as well? How do you intend to get out of that "loop"? Pressing the optionKey is not likely to be the best way, no?
Craig
Why not simply use a single "mouseUp" handler? Any reason to split them? Extra credit: Can you rewrite as a single handler just in case this would work just as well? How do you intend to get out of that "loop"? Pressing the optionKey is not likely to be the best way, no?
Craig
Re: A graphic that change the color all time

Well if we split them we can use the startFlash from another button and at the same time I don't think the "send "startFlash" to me in 30" will work inside a mouseUp, at least seem strange.
I'll show you how I implemented your code:
Code: Select all
on startFlash
Global vFlash
if vFlash = 0 then exit to top
put 0 into count
repeat with count = 0 to vFlash
add 1 to count
if the backgroundcolor of graphic "s1" of group ("legend" & count) = "red" then set the backgroundcolor of graphic "s1" of group ("legend" & count) to 217, 0, 0 else set the backgroundcolor of graphic "s1" of group ("legend" & count) to "red"
if the backgroundcolor of graphic "s2" of group ("legend" & count) = 241, 113, 51 then set the backgroundcolor of graphic "s2" of group ("legend" & count) to 236, 86, 36 else set the backgroundcolor of graphic "s2" of group ("legend" & count) to 241, 113, 51
send "startFlash" to me in 30
end repeat
end startFlash

I hope you understood and that my implementation don't seem so horrible

English is not my mother tongue
Re: A graphic that change the color all time
Hi Asha,
okie dokie
Maybe a couple of things:
1. Since you actually start your repeat loop at 1, you do not need to additionally manage a counter!
2. I am sure the "send startFlash..." should go OUTSIDE AFTER the repeat loop, right?
3. I added some CRs and "end if"s to make the whole thing better readable
Best
Klaus
okie dokie

Maybe a couple of things:
1. Since you actually start your repeat loop at 1, you do not need to additionally manage a counter!
2. I am sure the "send startFlash..." should go OUTSIDE AFTER the repeat loop, right?
3. I added some CRs and "end if"s to make the whole thing better readable

Code: Select all
on startFlash
Global vFlash
if vFlash = 0 then
exit to top
end if
## put 0 into count
repeat with count = 1 to vFlash
## add 1 to count
if the backgroundcolor of graphic "s1" of group ("legend" & count) = "red" then
set the backgroundcolor of graphic "s1" of group ("legend" & count) to 217, 0, 0
else
set the backgroundcolor of graphic "s1" of group ("legend" & count) to "red"
end if
if the backgroundcolor of graphic "s2" of group ("legend" & count) = 241, 113, 51 then
set the backgroundcolor of graphic "s2" of group ("legend" & count) to 236, 86, 36
else
set the backgroundcolor of graphic "s2" of group ("legend" & count) to 241, 113, 51
end if
end repeat
## Only seend ONCE and AFTER the repeat loop, right?
send "startFlash" to me in 30
end startFlash
Klaus
Re: A graphic that change the color all time
haha why not simply use a, wow I dont even know what it is lololololol. Trying to learn to code proving difficult,dunbarx wrote:You get an "A".
Why not simply use a single "mouseUp" handler? Any reason to split them? Extra credit: Can you rewrite as a single handler just in case this would work just as well? How do you intend to get out of that "loop"? Pressing the optionKey is not likely to be the best way, no?
Craig
Re: A graphic that change the color all time
Alex
Learn to code is one of the most satisfactory thing that I did.
I know at first is confusing and strange, a lot of different languages out there.. I pick up a bit of each, the base of all of them is the same and is easier every time
Learning to program is exponential, every small step helps you to make bigger steps.
now learn what is a "mouseUp" handler

Learn to code is one of the most satisfactory thing that I did.
I know at first is confusing and strange, a lot of different languages out there.. I pick up a bit of each, the base of all of them is the same and is easier every time

Learning to program is exponential, every small step helps you to make bigger steps.
now learn what is a "mouseUp" handler

English is not my mother tongue