# Counting button clicks in an Array with AS3

**URL:** <https://forum.kirupa.com/t/counting-button-clicks-in-an-array-with-as3/324522>\
**Category:** flash\
**Created:** [August 25, 2011, 11:59am UTC](https://forum.kirupa.com/t/counting-button-clicks-in-an-array-with-as3/324522 "2011-08-25T11:59:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![netmonkey](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@netmonkey](https://forum.kirupa.com/u/netmonkey)\
**Post date:** [August 25, 2011, 11:59am UTC](https://forum.kirupa.com/t/counting-button-clicks-in-an-array-with-as3/324522/1 "2011-08-25T11:59:41Z")

</div>

Hi,  
I have an array example from a Flash Connection tutorial, and I’m wondering if there’s an easy way to add a bit of code to count through the user’s clicks.

What I’m trying to do is count the clicks, so that once someone has clicked on all 5 buttons, something happens.

```auto
var clipArray:Array = [home_mc, about_mc, products_mc, services_mc, contact_mc];
for (var i:int = 0; i < clipArray.length; i++) {
    clipArray*.buttonMode = true;
    clipArray*.addEventListener(MouseEvent.CLICK, clickHandler);
}
function clickHandler(event:MouseEvent):void {
    switch (event.currentTarget) {
        case home_mc :
            trace("home");
            break;
        case about_mc :
            trace("about");
            break;
        case products_mc :
            trace("products");
            break;
        case services_mc :
            trace("services");
            break;
        case contact_mc :
            trace("contact");
            break;
    }
}

```

// E.g: If all five buttons are clicked, do something:

if (clipArray.length == 5) {

gotoAndStop(“WellDone”);

}

This counts the length, but not on clicks…

Any ideas? Thanks!
