# Help With Changing Variable

**URL:** https://forum.kirupa.com/t/help-with-changing-variable/193887
**Category:** programming
**Created:** [July 19, 2006, 1:40am UTC](https://forum.kirupa.com/t/help-with-changing-variable/193887 "2006-07-19T01:40:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![adzicents](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/adzicents/32/2574_2.png) [@adzicents](https://forum.kirupa.com/u/adzicents)
#### Post date: [July 19, 2006, 1:40am UTC](https://forum.kirupa.com/t/help-with-changing-variable/193887/1 "2006-07-19T01:40:02Z")

</div>

Okay I need a button to change the value of a variable…

This is the code to define the variable:

```auto
var numOfBalls:Number = 10;

```

And this is the code i currently have for the button (that doesn’t work):

```auto
on (release) {
 _root.numOfBalls+=1;
}

```

I need the button (named ‘addOne’) to add 1 to the variable (10 to 11, 11 to 12) and i also need another button to decrease the variable by 1 (12 to 11, 11 to 10) but the one which adds should only be able to add until the variable reaches 20, and decrease should go until 1.

Any help appreciated  
-Adam
