There are numerous reasons why you might want to implement a counter in a mobile app. You might want to count the number of items on a screen (that is, cold pieces in a game), the number of players using your app simultaneously, and so on. One of the easiest methods of counting is to use a loop. This recipe shows you how to easily implement a loop.
Use the following steps to instantiate a loop that counts:
Create a new main stack.
Rename the stack's default card to
MainScreen
.Drag a label field to the card and name it
counterDisplay
.Drag five checkboxes to the card and place them anywhere. Change the names to
1
,2
,3
,4
, and5
.Drag a button to the card and name it
Loop to Count
.Add the following code to the
Loop to Count
button:on mouseUp local tButtonNumber put the number of buttons on this \ card into tButtonNumber if tButtonNumber > 0 then repeat with tLoop = 1 to tButtonNumber set the label of btn value(tLoop) to \ "Changed...