A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [Help] Bank Account

  1. #1
    Impressive Click swcAndrew's Avatar
    Join Date
    Oct 2004
    Location
    USA
    Posts
    468

    [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.
    Andrew Webster
    Impressive Click

  2. #2

  3. #3
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    hehe, bingo

  4. #4
    Impressive Click swcAndrew's Avatar
    Join Date
    Oct 2004
    Location
    USA
    Posts
    468
    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?
    Andrew Webster
    Impressive Click

  5. #5

  6. #6
    Impressive Click swcAndrew's Avatar
    Join Date
    Oct 2004
    Location
    USA
    Posts
    468
    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));

    Andrew Webster
    Impressive Click

  7. #7
    Senior Member kendude's Avatar
    Join Date
    Sep 2003
    Location
    Hartford, CT USA
    Posts
    877
    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.

  8. #8
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    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.

  9. #9
    Impressive Click swcAndrew's Avatar
    Join Date
    Oct 2004
    Location
    USA
    Posts
    468
    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.
    Andrew Webster
    Impressive Click

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center