# Beginner question - Arrays and for loops

**URL:** <https://forum.kirupa.com/t/beginner-question-arrays-and-for-loops/304045>\
**Category:** flash\
**Created:** [January 31, 2010, 6:19pm UTC](https://forum.kirupa.com/t/beginner-question-arrays-and-for-loops/304045 "2010-01-31T18:19:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toussant](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@toussant](https://forum.kirupa.com/u/toussant)\
**Post date:** [January 31, 2010, 6:19pm UTC](https://forum.kirupa.com/t/beginner-question-arrays-and-for-loops/304045/1 "2010-01-31T18:19:07Z")

</div>

good day gentlemen, and ladies.

This is fairly simple to most of you, but it will revolutionize my flash experience once i can get past this.

I’d like to add event listeners to movieclips ( already on the stage ), whose names are called from an array one by one, into a for loop.

```auto

// there are 4 movielcips on the stage with name a1 - a4.
 
 // create array 
 var Bro:Array = ["a1","a2","a3","a4"];
 
 // for loop
 for ( var i:Number = 0; i < 4; i++) {
 
     // Add event listener to array values to buttons.
     Bro*.addEventListener(MouseEvent.ROLL_OVER, roll, false, 0, true);
     
     //execute this function on rollover
     function roll() {
         trace("why wont my arrays work in for loops");
     }
 }

```

- peace and love from New York City
