|
-
Impressive Click
[Help] Bank Account
ok I am having this problem. I am making this bank which displays money in the bank and money in your pocket. so i have two variables:
code:
money // pocket money
bank_amm // bank money
and when the player wants to withdraw I allow a input text box with a var name as "withdraw" and they type in the number of dollars they want to withdraw. So once they type a number and hit ok(button), this is what I type in its properties:
code:
on (press) {
_root.money += withdraw;
_root.banl_amm -= withdraw;
}
everything works except when I try and add the ammount to _root.money it just takes the number in money and then number in withdraw and puts them next to each other.For example:
my money is 400
if I type in 300 in the withdraw my money variable turns into 400300.
I can't figure out what I did wrong and I know once i realize it, I am going to feel stupid. Please help.
-
-
DOT-INVADER
hehe, bingo
-
Impressive Click
wow I didn't even see that thread. Sorry for making a repeat. I just have one more question, which was mentioned in the other thread as well.
I want it to be only numerical characters, but when I change the character option to numerical I can still type in letters. Am i using it the for the wrong purpose?
How do you use parseFloat()? Would that be better?
-
-
Impressive Click
the explanation was vague, so where would I insert the parsefloat?
Would I insert it in the frame, or on the ok button likes this:
code:
_root.money = parsefloat(-(-money_bank -withdraw));
-
Senior Member
Put it wherever the function is that takes the input box's data (prior to any calculation), that's where you want to extract the numbers. If you want to use parseFloat, I would do that to each var to make sure it was a legit number. Then do your computations.
-
Hype over content...
I just use int() for things like that. Boring but true.
code:
_root.money = int(money_bank+withdraw));
"the explanation was vague, so where would I insert the parsefloat?
Would I insert it in the frame, or on the ok button likes this"
Didn't you even try it before posting back here ???
Squize.
-
Impressive Click
yea I tried it but it didn't work on the button so reason for my question was to see if it was on the frame. If it was on the frame then I would ask how to set it up. Sorry if you found it annoying.
btw the int() thing worked, so thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|