# Assigning array elements to objects on stage

**URL:** <https://forum.kirupa.com/t/assigning-array-elements-to-objects-on-stage/147021>\
**Category:** Uncategorized\
**Created:** [May 6, 2005, 7:57am UTC](https://forum.kirupa.com/t/assigning-array-elements-to-objects-on-stage/147021 "2005-05-06T07:57:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![visitor13](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@visitor13](https://forum.kirupa.com/u/visitor13)\
**Post date:** [May 6, 2005, 7:57am UTC](https://forum.kirupa.com/t/assigning-array-elements-to-objects-on-stage/147021/1 "2005-05-06T07:57:48Z")

</div>

I have built an array of colors that I want to assign to clips on stage but there is something missing in a script and I’m stuck:  
[AS]  
//create a script assigning RGB color to a clip  
function combineRGB (red, green, blue) {  
//combine the color values into a single number  
var RGB = (red \<\< 16) | (green \<\< 8) | blue;  
return RGB;  
}  
MovieClip.prototype.setRGB = function (colorValue) {  
new Color (this).setRGB (colorValue);  
};  
//set color values  
color1 = combineRGB (76, 98, 139);  
color2 = combineRGB (124, 54, 52);  
color3 = combineRGB (92, 92, 118);  
color4 = combineRGB (119, 91, 80);  
//declare a new Array: “colors” for retrieving values later  
colors = new Array ();  
for (i = 1; i \< 4; i++) {  
colors\* = [“color” + i];  
//trace (colors\*);  
//the following should(?) assign color\* to box\* (boxes are objects on stage)  
this[“box” + i + “\_mc”].setRGB (colors\*);  
}  
[/AS]

I can assign one of the colors to all the boxes and it works:  
this[“box” + i + “\_mc”].setRGB (color5);  
but that’s not quite the effect I’m looking for :{
