How to create a number generator
In this example, you will learn how to create a number generator that will give a random number between 1 and 100.
Here’s how you build it:
View
Select “Text” and place it on the canvas and set the value to 0; next, select a “Button” and place it next to the 0.
Events
With the button selected, go to the Events palette and click “Add event”.
- In the dialog box, click on “Choose Trigger”, hover over the “Mouse” section and select “on Click”.
- In “Choose Action”, select “Set value to an element” and select the “0”.
- Select the “Calculated” radio button for the value and click “Add expression”.
- In the value expression builder first field, select the “Rand” from the “Constants” tab and multiply it by 100: this expression will give you an infinite number of results due to the decimals.
- We will modify our expression to round the numbers by adding a “Round”. Select the function “Round” and place it in front of the expression; once set, the last field will be enabled; give it the value “0” to eliminate the decimals from the expression. Click “OK” and “OK” to finish creating the event.
Simulate your prototype.