# gotoAndPlay(x),x from an Array

**URL:** <https://forum.kirupa.com/t/gotoandplay-x-x-from-an-array/203289>\
**Category:** flash\
**Created:** [October 9, 2006, 9:22pm UTC](https://forum.kirupa.com/t/gotoandplay-x-x-from-an-array/203289 "2006-10-09T21:22:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [October 9, 2006, 9:22pm UTC](https://forum.kirupa.com/t/gotoandplay-x-x-from-an-array/203289/1 "2006-10-09T21:22:03Z")

</div>

Hello guys,

I have a problem, i want to gotoAndStop a movieClip when i RollOver a btn. I have a total of 6btn and my mc has 6 frames. I sad that it is easy to use array’s, so i develop this code (but i see that it is not working ☹ )! Can somebody help me;

Short description of the code:  
BackgroundArray = the array that contains the frame to go to;  
SubBtnArray = the array that contains the instancenames for my btns;

```auto

var root:MovieClip = this;
var subBtnArray : Array = new Array (_sHome, _sColectii, _sMagazine, _sColectiiPers, _sNews, _sContact);
var BackgroundArray : Array = new Array ("2", "3", "4", "5", "6", "7");
//tried with var BackgroundArray : Array = new Array (2, 3, 4, 5, 6, 7); but no result!
for (var nrBG : Number = 0; nrBG < BackgroundArray.length; nrBG ++)
{
    for (var nrSubBtn : Number = 0; nrSubBtn < subBtnArray.length; nrSubBtn ++)
    {
        subBtnArray [nrSubBtn].onRollOver = function ()
        {
            root._subMeniuBara._alpha = 100;
            root._bg.gotoAndStop (BackgroundArray [nrBG])
            root._subMeniuBara._y = this._y
        }
        subBtnArray [nrSubBtn].onRollOut = function ()
        {
            root._subMeniuBara._alpha = 0;
        }
    }
}

```

Can somebody help me resolving this?

Thank you in advance, btibia :thumb2:
