# Increment a global variable one button press at a time?

**URL:** <https://forum.kirupa.com/t/increment-a-global-variable-one-button-press-at-a-time/237538>\
**Category:** Uncategorized\
**Created:** [August 31, 2007, 7:17am UTC](https://forum.kirupa.com/t/increment-a-global-variable-one-button-press-at-a-time/237538 "2007-08-31T07:17:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragemaster](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@ragemaster](https://forum.kirupa.com/u/ragemaster)\
**Post date:** [August 31, 2007, 7:17am UTC](https://forum.kirupa.com/t/increment-a-global-variable-one-button-press-at-a-time/237538/1 "2007-08-31T07:17:40Z")

</div>

what I am trying to do is use a Switch index to controll movie clips  
with a button to advance to the next case: statement and when I have reached the end  
of the case: index go back to the case: 0; and start all over again.

what I need is a global variable and give it a value of 0  
var clipsVariable:int = 0;  
var goalreset:int = 10;

function onClick(event:MouseEvent):void{

is clipsVariable \< goalrest

clipsVariable = 0;  
else  
add 1 to clipsVarable  
call switch ();  
}

I seem to have the somthing scrood up because the switch does not see the clipsVariable  
and so go into an endless loop any ideas?
