# Quick Array + Loop Question

**URL:** <https://forum.kirupa.com/t/quick-array-loop-question/144648>\
**Category:** Uncategorized\
**Created:** [April 15, 2005, 7:44pm UTC](https://forum.kirupa.com/t/quick-array-loop-question/144648 "2005-04-15T19:44:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abcdefg](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@abcdefg](https://forum.kirupa.com/u/abcdefg)\
**Post date:** [April 15, 2005, 7:44pm UTC](https://forum.kirupa.com/t/quick-array-loop-question/144648/1 "2005-04-15T19:44:23Z")

</div>

I’m making a really simple color chooser.

Basically I have an array which holds my colors. I have a movieclip on which i duplicate depending on the array’s length. Then I fill the movieclips with the proper colors stored in the array.

Now I’d like to make it so when the user clicks a movieclip(chooses a color) I want to trace that color value.

Right now, no matter what color I choose the last array element(RGB Color) get’s traced.

So if I choose black, it traces green(last color in the array).

```auto

myColors = new Array("0xFF000", "0x666666", "0xE3E3E3", "0xFFDEAD", "0x003300");
spacing = holder._width + 35;
holder._visible = false;
for (i = 0; i < myColors.length; i++) {
    holder.duplicateMovieClip("newholder" + i, i);
    newholder._x = 200;
    mc = this["newholder" + i];
    mc._x = spacing * i;
    clr = this.myColors*;
    a = new Color(mc);
    a.setRGB(myColors*);
    mc.onPress = function() {
        trace(clr);
    };
}

```
