This content has been marked as final. Show 11 replies
I'm not really sure if i understand your problem (providing the fla would do the trick though i guess)
If you wnat the value of c trced you should use
trace("c = "+a+b);
if your result for the case a = 1 and b = 2 isn't "3" but "12", then a and b were treated as strings nut as numbers (depends on how you define a and b)
You should use
trace ("c = "+Number(Number(a) + Number(b)));
(that is the 110 % way ;-))
Many tx "2m" for your kind reply, truly appreciate it...you got my question right and the "logic" of your reply is true...BUT, I don't know what I has done wrong, it still replies me "NaN". The coding is as simple as below. I got field a, b and c. If 3 of the fields are string, no problem it concatenate a and b. As soon as I want to calculate a+b, it doesn't work:
(c.text = a.text + b.text);
as per your advise, I changed it to:
("c = "+Number(Number(a) + Number(b)));
Pls comment and highlight. Many tx.
Maybe you could provied the fla, and I could take a look, that might shorten the process ;-)
Morning 2m: Good idea to send you the fla as it's respectively small, just 3 lines of code but when i click on the attach code, it gives me a screen to include raw html code?!
Rothrock: I tried yours, same problem NAN. Many thanks!
as mentioned by 2m, could be some timy mistake I made, which myself believe so but I have caught on this for sometime
Well mine covers the basics – there may well be a scope issue.
You need to do some traces to see where your info is going bad. So do this:
trace("The text of a is: "+a.text);
trace("The value of a is: "+parseFloat(a.text);
What do you get with that?
BTW, you can't attach a whole FLA with the attach code button. That is only for pasting in code that you copy out of your file. But we know that isn't working so attach code won't help you here.
by providing the fla, I ment that you could upload it to some server and tell us the url to download it.
(If that's not an option, send me a private message with your email, I'll answer and you can send it to me via email)
Nice to know that I have helped making you happy.
Don't tell my wife though ;-)
So what was the trick? Please share so that anybody else who finds this thread can learn from you.
I wanted to share and not hoping anyone will be caught as me and "shy" to ask this question as it's simply...sorry to trouble you all....BUT......
I may only say I "suspect" "event" is the culprit....when I do "onSetFocus", both of your (2m & Rothrock codes) work, BUT "onPress", it doesn't work. Anyhow, strangley when I change the instance name to a, b & c, instead of using cName,fname&lName, it works.
Logically I don't see the instance name is the cause...I really get quite confuse but no more time for me to futher explore...need to rush for projects....
Anyhow, many thanks...and for those who caught with this - good luck!!!