# Adding to a Variable

**URL:** <https://forum.kirupa.com/t/adding-to-a-variable/2587>\
**Category:** flash\
**Created:** [May 31, 2002, 4:07pm UTC](https://forum.kirupa.com/t/adding-to-a-variable/2587 "2002-05-31T16:07:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 31, 2002, 4:07pm UTC](https://forum.kirupa.com/t/adding-to-a-variable/2587/1 "2002-05-31T16:07:21Z")

</div>

Wow, I thought I knew Flash until I decided to learn ActionScript. Now even the most basic things are taking me forever to learn. So I apologize for my newbieness, I’m really smart, I promise!

Anyways, here’s my easy question of the day. I have a variable i that I’m setting to 5. i = 5. Simple enough, I have a dynamic box on the screen so I know that’s working.

On the same screen, I have a button, that when you click it, it should do the function i = i + 1. I know this isn’t working because when I click it, the number on the screen doesn’t change.

Also I have a second button that is a collection of if/else if statements. Basically, if i=1, goto 10, else if i\<1, goto 40, else if i\>1, goto 40. I know that since I’m setting the initial value of i to 5, it’s impossible for i to be equal to 1. Yet every time I click this button, I goto 10 even though i doesn’t equal to 1.

Can anyone help out on these two problems? Am I not using the variable i correctly here?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 31, 2002, 4:15pm UTC](https://forum.kirupa.com/t/adding-to-a-variable/2587/2 "2002-05-31T16:15:14Z")

</div>

After mucking with my code on the button that increments the i variable, I figured out that the button is indeed working, just the screen wasn’t refreshing. Anyways, now that I know that’s working, I know my problem is something with the if then statement I’m working with.

Here’s the exact code I’m working with that’s not working for me:

on (release) {  
&nbsp &nbsp &nbsp &nbsp if (i = 1) {  
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndPlay (10);  
&nbsp &nbsp &nbsp &nbsp } else if (i \> 1) {  
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndPlay (40);  
&nbsp &nbsp &nbsp &nbsp } else if (i \< 1) {  
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp gotoAndPlay (40);  
&nbsp &nbsp &nbsp &nbsp }  
}

Please help, it seems basic enough yet for some reason, even though i isn’t each to 1, I’m always going to frame 10!!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 31, 2002, 4:51pm UTC](https://forum.kirupa.com/t/adding-to-a-variable/2587/3 "2002-05-31T16:51:04Z")

</div>

Ah ha, so it’s supposed to be i == 1 and not i = 1 in the if then statement. Don’t you feel smart when you solve problems on your own? Too bad that took up 3 hours of my afternoon. Thanks anyways for the help, I’m sure I’ll be back later for more help.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 31, 2002, 5:08pm UTC](https://forum.kirupa.com/t/adding-to-a-variable/2587/4 "2002-05-31T17:08:45Z")

</div>

welcome to the boards. Sorry I didn’t catch this post sooner. I was busy with my projects. Again, welcome.
