Sets the screen to the given screenId.
Most apps are not constructed with only one screen, but have multiple screens for the user to interact with. Maybe first a logon screen, then the screens for the app itself, ending with "game over" or "thank you" screen possibly including a "play again" option. Each screen has its own UI elements with corresponding event handlers.
// Screen swap. screen2, textLabels and buttons were added in Design mode. onEvent("screen1button", "click", function(event) { setScreen("screen2"); }); onEvent("screen2button", "click", function(event) { setScreen("screen1"); });
setScreen(screenId)
Name | Type | Required? | Description |
---|---|---|---|
screenId | string | The unique identifier for the screen. Must begin with a letter, contain no spaces, and may contain letters, digits, - and _. |
No return value. Modifies screen only.
Found a bug in the documentation? Let us know at documentation@code.org