Flash an image on and off

I want to flash an image on and off.
that is show image, wait a second, show blank, then show image, repeat...

as a first attempt i tried the following where delay is a procedure that works and delays for a set amount of time. but the routine doesn't work. any help please?

You should try using a clock timer to do that.

delay is a procedure that uses system clock to wait a set amount of time.
so shouldn't this logic work?
show image
delay
hide image

and put that all in a for loop?

it dosesn't work and trying to understand why.

thanks

No, not that, use Clock1.Timer

Something like this:

image

Why is a wait procedure generally a bad idea?
The model of event processing in App Inventor by Lyn
therefore use a clock
Please Wait method by Scott

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

thanks. was using Scott's please wait procedure which makes a ton of sense to me.........But althugh his code works fire for me in his example, if I change texttospeech to some other code it doesn't work strangely.

thank you for that link, I now added a comment there to never use a delay procedure, which also links back to this thread

Taifun

Why never use a delay procedure? its kind of a neat trick.
grab system time and store in variable ctime
do nothing until system time > ctime + 1000 (say)

makes a lot of sense to me from a programming perspective.

in short: because it blocks the device
for the long version see again Why is a wait procedure generally a bad idea?

Taifun
PS: I probably better should have said "generally never use a delay procedure"...

It is not written anywhere whether it is a synchronous or asynchronous delay. If the latency is asynchronous and the application does nothing and does not block the phone during the delay, then that's okay.
If the delay is synchronous and it blocks the main thread of the program, such as "delay" in c ++, it's not a good idea.

App Inventor is single threaded... which means we are talking about a synchronous delay, which means

Taifun

1 Like