What I'm going to explain?
We have a variable and we want to display it in a text box, for example a health variable. I also explain how to make a variable
How will we do it?
1) First draw a simple text box in your Flash with the text tool.
2) Select your text box and at properties around the upper left there is a dropdown menu.
3) Open the dropdown menu and select Dynamic Text.
4) Under the dropdown menu there is a little input Textbox, type the name of how you want it to be called, I chose healthShow
5) Now we'll start with the code, first add:
addEventListener(Event.ENTER_FRAME, healthScore);
Note that healthScore can be anything, it's just how you want to call the listener.
6) You need to now how to make a variable if not, read step 7 first
Afterwards we tell Flash what the function is of healthScore
function healthScore (event:Event){
healthShow.text = String ("Health:"+health);
}
Note that when we tell the name of the textbox we made, with us it's healthShow, you need to add .text behind it. I tell what healtShow is, a string, and tell what it is, the text between (). I say that the string consists of the text Health:, we need to put this in brackets, because we only want the text. We don't want to have in this text only Health:, we also want to show the value of our health variable, so we say to Flash: 'After the text Health: show the value of our health variable, we do this by putting after "Health:" this: +health
7) type in Flash in the AS box the following:
var health:Number = 3;
Note that you can also replace Number with int or uint. These are the differences
Number can display all types of numbers, whole or a real (eg. 6,459). Positive and negative
int can display only whole numbers and can't go lower than -3
uint can display only whole numbers and can't be negative
8) to help you guys out and to not get you confused I'll post here the complete code
// set up the health variable
var health:number = 3;
// add listener
addEventListener (Event.ENTER_FRAME, healthShow);
function healthShow (event:Event){healthScore.text = String ("Health:"+health);
}
It is possible that I've made a mistake, if so leave a comment or PM me and I'll try to help you out