all groups > flash actionscript > september 2007 >
You're in the

flash actionscript

group:

Issue with Adding numbers to a textbox


Issue with Adding numbers to a textbox nonybd
9/30/2007 11:33:55 PM
flash actionscript: Hi,

I have a flash document,where each time you click a button, a text box adds 1
to the value, from the origonal value of 0, on and on, like so:
0 <button is clicked> 1 <button is clicked> 2 <button is clicked> 3 ...
but instead, it gives me:
0 <button is clicked> 01 <button is clicked> 011 <button is clicked> 0111
How do I convert the text-box object to didgits, instead of text?
This is the actionscript:



the_button.onPress = function (){
text_box.text += 1;
}
//And i tried
the_button.onPress = function (){
text_box.text = text_box.text + 1;
}
Re: Issue with Adding numbers to a textbox kglad
10/1/2007 12:00:00 AM
Re: Issue with Adding numbers to a textbox kglad
10/1/2007 12:07:43 AM
Re: Issue with Adding numbers to a textbox nonybd
10/1/2007 12:27:41 AM
Thanks for the reply
I looked up the Number() function in help, and I changed the code to the code
below. That fixed the previous problem, but the new issue is that it only goes
up to 1. Is there an issue with my AS? Thanks

var the_box:Number = text_box.text;
the_button.onPress = function (){
text_box.text = Number(the_box) + 1;
}
Re: Issue with Adding numbers to a textbox Craig Grummitt
10/1/2007 2:30:21 AM
you are setting the_box at the beginning, and then when the button is pressed
you add one to it each time. if you want to add to the number in the textbox
each time, you need to calculate from that in the onPress handler eg:

the_button.onPress = function (){
var the_box:Number = text_box.text;
text_box.text = Number(the_box) + 1;
}
AddThis Social Bookmark Button