# Button not working

**URL:** <https://forum.kirupa.com/t/button-not-working/257953>\
**Category:** Uncategorized\
**Created:** [April 18, 2008, 7:34pm UTC](https://forum.kirupa.com/t/button-not-working/257953 "2008-04-18T19:34:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)\
**Post date:** [April 18, 2008, 7:34pm UTC](https://forum.kirupa.com/t/button-not-working/257953/1 "2008-04-18T19:34:17Z")

</div>

all this resides on frame 2 of the root timeline.

```auto

stop ();
//create new array named rules
var rules:Array = new Array();
rules [0] = "Hello and welcome";
rules [1] = "This is a test array";

//tells storybox.txt to display first item in array
rules_mc.storyBox_mc.storyBox_txt.text = rules[0];

//sets event listener for button
rules_mc.storyBox_mc.nextBtn_mc.addEventListener (MouseEvent.CLICK, nextStatment);
rules_mc.storyBox_mc.nextBtn_mc.buttonMode = true;

//function for event listener
function nextStatment (event:MouseEvent):void
{
    var index:Number = 0;

//holds lenght of rules array
    var arrayLen:Number = rules.length;

//increase index value on click
    index++;

    rules_mc.storyBox_mc.storyBox_txt.text = rules[index];
//shows the current indes of the rules array in text field   

 if (index == rules.length)
    {
// if the index number is the same as the array length go to next frame on root imeline.
        gotoAndPlay ("setup");
    }

}

```

my problem is that when i click my button the array length and the index number are never the same so it will never go to the next frame any way i can get around this little predicament?
