I have a code block, shown below;
I want to update the Duration.text
every second. How can I achieve it?
I have a code block, shown below;
I want to update the Duration.text
every second. How can I achieve it?
Use a Clock component ans put your blocks into the Clock.Timer event
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock
A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .
Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
I have already using a timer block in the app and I have tried to put the Duration.text
block in clock.timer
it is not updating every after second. What am I doing wrong here?
This code updates the Duration.text
only when timer ends.
Maybe this call/update section is consuming more portion of 1000 millis,
What this section is doing.
To set timer enabled to false stops the clock...
Also remove all irrelevant blocks...
Only ask for permission once...
Taifun
Point1 - Timer interval must be 1000ms inorder to get value for every seconds..
Point2 - And you should not set clock timer enabled to false in when clock timers event block
Thanks for helping me with the issue. I have got the label update as I needed by following the suggested changes. Complete code blocks are below;
This block initializes a variable
while.test
block but when I use this while.test
block the app becomes unresponsive and crashes.
the duration is positive in your case, isn't it?
you should put an if statement into the Clock.Timer event like this
if duration < 0
then do something
Taifun