# \[mx\] trying to count when all buttons have been clicked

**URL:** <https://forum.kirupa.com/t/mx-trying-to-count-when-all-buttons-have-been-clicked/7335>\
**Category:** flash\
**Created:** [October 28, 2002, 9:24pm UTC](https://forum.kirupa.com/t/mx-trying-to-count-when-all-buttons-have-been-clicked/7335 "2002-10-28T21:24:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clearly](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@clearly](https://forum.kirupa.com/u/clearly)\
**Post date:** [October 28, 2002, 9:24pm UTC](https://forum.kirupa.com/t/mx-trying-to-count-when-all-buttons-have-been-clicked/7335/1 "2002-10-28T21:24:42Z")

</div>

I’m trying to create a loop of some kind. I haven’t done these before and I’ve tried searching the forum, but I’m still stuck. Not to mention, I still don’t understand the difference between a for, while, and do loop, but I will tackle those later.

For now I have several buttons that need to be clicked before the user can proceed. I am trying something like this:

on a mc I have the following:

onClipEvent (load) {  
counter = 0;  
}

onClipEvent (enterFrame){  
if (counter \>= 5) {  
next\_bttn.enabled = true;  
}  
}

on each button:

on (release) {  
counter++;  
}

Am I heading in the right direction?

---

<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:** [October 29, 2002, 7:07am UTC](https://forum.kirupa.com/t/mx-trying-to-count-when-all-buttons-have-been-clicked/7335/2 "2002-10-29T07:07:02Z")

</div>

um you would probably have to have a separate variable for each button…and when its clicked then the value is true…if it isn’t then the value is false. you could name these like button1, button2, etc…and then have a loop like

```auto

while(i<numberOfButtons){
if(button1=true){
do something
}

```

---

<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:** [October 29, 2002, 7:59pm UTC](https://forum.kirupa.com/t/mx-trying-to-count-when-all-buttons-have-been-clicked/7335/3 "2002-10-29T19:59:15Z")

</div>

on the buttons you need to target the mc. The variable “counter” doesn’t exist on the same timeline as the buttons.

just add the movieclip’s name to the counter call, i.e.

```auto
 on (release){
_root.myMovieClip.counter ++;
}

```

I think that’s right.
