# In a loop, set color of stage instances

**URL:** <https://forum.kirupa.com/t/in-a-loop-set-color-of-stage-instances/268118>\
**Category:** Uncategorized\
**Created:** [August 10, 2008, 4:04am UTC](https://forum.kirupa.com/t/in-a-loop-set-color-of-stage-instances/268118 "2008-08-10T04:04:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![serostar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@serostar](https://forum.kirupa.com/u/serostar)\
**Post date:** [August 10, 2008, 4:04am UTC](https://forum.kirupa.com/t/in-a-loop-set-color-of-stage-instances/268118/1 "2008-08-10T04:04:58Z")

</div>

Hi,

I’m reading an XML file, receiving the hex value, then setting the color of an object on the stage using Tweener. There are 88 objects (keys on a keyboard).

Here’s the code I’m using:

```auto
function ParseColors(bookInput:XML):void {
  var i:Number = 1
 
  while (i < 88) {
 
  var k = (bookInput.key.k.text()*); //this is the number of the key
  var khex= (bookInput.key.hex.blank.text()*);
 
  var theKey = "k"+i;
 
  trace(theKey);
  trace(khex);
 
  Tweener.addTween(theKey, {_color:khex, time:2});
 
  i++;
 
  }
 
 }

```

The traces show everything correctly, but Tweener throws errors when it tries to set each key to it’s corresponding colors.

The keys are on the stage with instance names k1,k2,k3,k4, etc.

I think I’m missing something silly, can anyone help out?
