Displaying a number to your user based on their interaction, or a script’s function, can be an extremely useful way to show progress, score, times, distances, and a whole host of other changing numbers. For this script we’ll look at using two buttons, a dynamic text box, and a few lines of code to understand how this is done.
Setting the stage
First, create a dynamic text box on your stage. Start out by typing in “000″ or as many places as you need for your score, to make sure your text box is the right size.
In the properties panel type “score” in the field that says “Var:”. This will link the variable to the number we’re changing. Center align the text box, and embed the Numerals of that font in the pop-up box with the button “Embed…” This is a way of saving the fonts to your SWF file to make sure all of the numbers 0-9 will be presented the way you want.

Understanding the script
Create a variable that acts as a placeholder for our score/number.
Make a function that adds 1 to the “score” variable each time the button is clicked.
To subtract from the number, create a second button and use -= instead of += like this:
Actions
Once you have your stage set up with the dynamic text field, place this script in your actions keyframe.
btn_scoreUp.onRelease = function() {
score += 1; // add 1 to score
}
btn_scoreDown.onRelease = function() {
score -= 1; // subtract 1 from score
}
Other uses
After you have this script working with your button(s), you can use it in your own code with timers, loops, and other user interactions like mouse clicks, moving/dragging graphics, or scrolling.
