Help for Blink Extension & Model of Execution in App Inventor

Hello,
I've working on an extension that will "blink" an arrangement component. The pseudo-code is as follows:

Repeat(10 times) {
  set bgcolor = "red"
  wait(1000ms)
  set bgcolor = "blue"
  wait(1000ms)
  }

I've figured out how to change the color and how to add a delay. But given the model of execution in App Inventor, UI changes are shown at completion. So when I call the function, nothing happens for 20 secs and then suddenly color changes to blue.

So my question is
Is it possible to actually "blink" the color multiple times in one function? Is there a workaround? How?

Also, I know that this can be easily done using blocks (Clock.Timer) but I want to know if it's possible using extension. I currently learning and experimenting with stuff.

PS: I'm a newbie in extension development, so don't laugh at my question...

You can create Clock component inside you extension.

Sound's good!
But as I told earlier, I'm new to extension development. I did look up in the MIT sources and template repository but I'm still clueless on how to get it to work.
Can I get atleast a hint on what I have to do? (How do I create a clock?)
Thank you for your sincere help.

here is a example of web component similarly you can create clock

The way the Clock component does this is by implementing the AlarmHandler interface and then instantiating a TimerInternal object to regularly call its alarm() method (which in turn fires the Timer event). You could use a similar approach and in the alarm method update the view.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.