# Arrays and a MovieClip gotoAndStop problem

**URL:** <https://forum.kirupa.com/t/arrays-and-a-movieclip-gotoandstop-problem/125826>\
**Category:** Uncategorized\
**Created:** [October 18, 2004, 4:15am UTC](https://forum.kirupa.com/t/arrays-and-a-movieclip-gotoandstop-problem/125826 "2004-10-18T04:15:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc0047](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@marc0047](https://forum.kirupa.com/u/marc0047)\
**Post date:** [October 18, 2004, 4:15am UTC](https://forum.kirupa.com/t/arrays-and-a-movieclip-gotoandstop-problem/125826/1 "2004-10-18T04:15:26Z")

</div>

I have 1 movieclip, called ‘copy’, and 10 other movieclips acting as a button, called ‘items’ 1 through 10, on a stage. Each ‘item’ button tells ‘copy’ to advance to the corresponding frame.

I am also using a for loop to help me generate the button actions.

I would like button ‘item1’ to advance to frame 1 of ‘copy’, ‘item2’ to advance to frame 2 of ‘copy’, and so on. But, what happens is that the ‘copy’ frame is always advancing to frame 10, regardless of which button is pressed.

If anyone can inform me of what I am doing incorrectly that would be great.

Here is my code:

items = [item1, item2, item3,… item10];

for (var i = 0; i \< items.length; i++) {  
items\*.onPress = function() {  
copy.gotoAndStop(i+1);  
}  
}
