App Lab - How to run code when changing to a new screen?

applab

#1

Hi,
My students have made a quiz game. Some of them would like to display a score on the final page. They have set up a variable that gets incremented when the correct answer is pushed. But cannot figure out how to display the score on the final screen.

My idea was to use a label and update the text to the variable, however, I am not sure how to run that code? There does not seem to be an event such as when screen1 is loaded or something.

Thanks in advance,

Craig


#2

Hi @mrbriggsteach - it sounds like you have the right idea! Can you share a link to the app here? You can do that by clicking “Share” in the top left corner and taking that URL. I can take a look at it!

KT


#3

@mrbriggsteach - You might have already figured this out but you can set the text for a text box that is not on the current screen so when you switch to the new screen it’s there. The attached program is a quick example: https://studio.code.org/projects/applab/-D7HgB9X93vBsvR1KZ4BPxdcsk0udr7b0x02M3U8H28