As a rule of thumb, do not EVER use
while (true) {
//do nothing
}
This tries to do nothing (which is a command that the CPU still has to process), every single CPU clock. The sole reason while
loops do not usually cause an ANR, is that they iterate and break very fast. In this case, your condition and action are not interdependent, thus breaking the block flow, and ultimately freezing the app.
Also, since App Inventor apps run on the UI thread, a delay procedure is what we call a “bad idea”.
Now, for the solution.
Make a Clock component with Timer.Enabled = false
, and Interval = 400
.
} else if (not(isEmpty?(Answer_Box.Text))) {
set Try_Again_Text.Text to "Try Again";
set Clock1.TimerEnabled to true;
}
Clock1.Timer {
set Clock1.TimerEnabled to false;
set Try_Again_Text.Text to "";
}
If you only show the text “Try Again” in that label, it is better to toggle visibility, and just make “Try Again” the text, through the Properties panel (Design tab).