PDA

View Full Version : Help with Imput Text Boxes



jose3760
July 9th, 2007, 10:28 AM
Im having a little bit of a probelm with my imput text box. In my game im creating, theres a bank that allows you to deposit any amout of cash$$$ that you type in. after you press "deposit", it goes to your balance, and displays it. but if you enter another amount and press deposit, it will add it to the end of the first amount, instead of addin them together


example:

I type 100, press deposit, and it goes to the blance. i type in 200, press deposit, and the balance will read "100200" instead of "300"

here is the code on the deposit button

on(press){
_root.balance = _root.balance + _root.deposit;
}


:crying:

Warheart
July 9th, 2007, 10:34 AM
Im having a little bit of a probelm with my imput text box. In my game im creating, theres a bank that allows you to deposit any amout of cash$$$ that you type in. after you press "deposit", it goes to your balance, and displays it. but if you enter another amount and press deposit, it will add it to the end of the first amount, instead of addin them together


example:

I type 100, press deposit, and it goes to the blance. i type in 200, press deposit, and the balance will read "100200" instead of "300"

here is the code on the deposit button

on(press){
_root.balance = _root.balance + _root.deposit;
}


:crying:

Hello, had this problem a while ago, the reason it is doing that is because flash sees it as a string. To fix you should just be able to go:
on(press){
_root.balance = Number(_root.balance) + Number(_root.deposit);
}

jose3760
July 9th, 2007, 10:45 AM
Thanks for the help, it works perfectly! :sure: