# I need some help hommies :-)

**URL:** <https://forum.kirupa.com/t/i-need-some-help-hommies/186649>\
**Category:** programming\
**Created:** [April 23, 2006, 6:27am UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649 "2006-04-23T06:27:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![studioxidesign](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@studioxidesign](https://forum.kirupa.com/u/studioxidesign)\
**Post date:** [April 23, 2006, 6:27am UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/1 "2006-04-23T06:27:19Z")

</div>

I’m trying to make a simple banking swf for a game them I’m starting to build.

WHAT TO USE::::  
2 dynamic text boxes - variables set to money & bank  
1 input text boxes - variable set to amount  
1 button

In the first frame of the game I declare the values that you will start out with.

stop();  
money = 500;  
bank = 0;  
amount = 0;

WHAT I WANT TO DO IS PROBABLY NOT HARD I JUST CAN’T THINK ANYMORE LOL. When you type in an amount into the input put it will subtracted the amount from the MONEY variable and add the amount to BANK, simulating that you’re depositing the cash into your account.

I got the sutraction to work but in the code I’m trying to subtract a variable from a variable and it’s not working… here’s the ACTIONS from the BUTTON

on(press){  
if(\_root.money \>= \_root.amount){  
\_root.money -= \_root.amount;  
\_root.bank += \_root.amount;  
}  
}

\_root.bank += \_root.amount; \<------ This is the line that’s not correct. basically what it’s doing is , let’s say you type is 10 in the amount text box it adds the 10 at the end of the 0 that’s already there so it’s like 0, 010, 01010, 0101010, 010101010 etc etc etc or if you type something else in it’s keeps continuing 01010101050 , 0101010105050, etc etc etc… If anyone could help me , it would be greatly appreciated.

Thanks,  
Brent  
Studio XI  
[www.studioxidesign.com](http://www.studioxidesign.com)

---

<div class="post-metadata">

**Author:** ![Nich](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@Nich](https://forum.kirupa.com/u/Nich)\
**Post date:** [April 23, 2006, 3:46pm UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/2 "2006-04-23T15:46:32Z")

</div>

Since “amount” comes from a text box, it’s concidered a string variable. Since you can’t add a string to an int, flash treats them both as strings and you get the effect you listed above. Gimme a sec to check the syntaxes, but I believe you can just use Int() to convert a string into an integer. (\_root.bank += Int(\_root.amount))

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 4:54pm UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/3 "2006-04-23T16:54:16Z")

</div>

Simple!

```auto

on(press) {
	if(_root.money >= _root.amount){
		_root.money = number(_root.money) - number(_root.amount);
		_root.bank = number(_root.bank) + number(_root.amount);
	}
}

```

---

<div class="post-metadata">

**Author:** ![studioxidesign](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@studioxidesign](https://forum.kirupa.com/u/studioxidesign)\
**Post date:** [April 23, 2006, 5:07pm UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/4 "2006-04-23T17:07:27Z")

</div>

> [@Crayon-Inc](#):
>
> Simple!
> 
> ```
> ActionScript Code:
> [FONT=Courier New][LEFT][COLOR=#0000ff]on[/COLOR][COLOR=#000000]([/COLOR]press[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
> 
> ```
> 
> if[COLOR=#000000]([/COLOR][COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]money[/COLOR] \>= [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]amount[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
> \_root.[COLOR=#000080]money[/COLOR] = [COLOR=#0000ff]number[/COLOR]COLOR=#000000[/COLOR] - [COLOR=#0000ff]number[/COLOR]COLOR=#000000[/COLOR];  
> \_root.[COLOR=#000080]bank[/COLOR] = [COLOR=#0000ff]number[/COLOR]COLOR=#000000[/COLOR] + [COLOR=#0000ff]number[/COLOR]COLOR=#000000[/COLOR];  
> [COLOR=#000000]}[/COLOR]  
> [COLOR=#000000]}  
> [/COLOR][/LEFT]  
> [/FONT]

[FONT=Courier New][LEFT]  
[/LEFT]  
[/FONT] Hey man I appreciate the help. I knew it wouldn’t be a hard script to write I just go brain dead after working 10-12 hour days.

Cheers,

Brent  
Studio XI  
[www.studioxidesign.com](http://www.studioxidesign.com)

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 5:32pm UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/5 "2006-04-23T17:32:41Z")

</div>

Your welcome :thumb2:

---

<div class="post-metadata">

**Author:** ![fenrir](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@fenrir](https://forum.kirupa.com/u/fenrir)\
**Post date:** [April 23, 2006, 9:14pm UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/6 "2006-04-23T21:14:40Z")

</div>

I’d like to see your game when it’s done!

-Fenrir

---

<div class="post-metadata">

**Author:** ![studioxidesign](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@studioxidesign](https://forum.kirupa.com/u/studioxidesign)\
**Post date:** [April 25, 2006, 6:24am UTC](https://forum.kirupa.com/t/i-need-some-help-hommies/186649/7 "2006-04-25T06:24:28Z")

</div>

> [@fenrir](#):
>
> I’d like to see your game when it’s done!
> 
> -Fenrir

absolutely, It’s not going to be anything super great considering this will be my first game in flash. I am a flash web developer so gaming is a new open door for me. I’ll be sure to keep you posted though

Take Care,  
Brent  
Studio XI  
[www.studioxidesign.com](http://www.studioxidesign.com)
