This content has been marked as final. Show 6 replies
what do u wanna do with those amounts? Convert them, add them together, what?
I want to add the two values and display the result in the totLabel.text as a dollar amount
Hey pcst88... You still out there?
total = amount1 + amount2;
But I suspect it is something more than that?
My guess is that you are taking these or one of these from a text field? In that case the value is going to be – get this – text!
You need to either parseFloat the variable to a number or you can try casting it with:
total = Number(amount1) + Number(amount2);
I must have tried that one a dozen times, in every possible combonation. My result was NaN.
Yes I am getting the values from other text fields. They are dollar ammounts (ie. 89.50)
Did you take a look at the files I posted? if not here they are:
Source .as file is here: http://home.comcast.net/~shane.swoboda/four01k.as
Flash file: http://home.comcast.net/~shane.swoboda/four01k.fla
It seems so straight forward but I can't figure it out... Ugh!
Sorry, but I don't generally download files from thes forums. Why don't you pull out the relevant bits and post them here?
The usual suspects are that you are trying to add them before the user (or whatever) has input the data. Or that you aren't converting one of them to a number.
Are you assigning them to an intermediate variable or are you trying to pull directly from the text field?
What happens if you do this:
trace("the value is ["+myTextField.text+"]");
right before you need to add them?
Also a good trick is to go to the debug menu in the testing environmnet and select "List variables" this will show you where everything is defined. Perhaps your textfields are not in the scope of where you are trying to add them?