# How to shorten this code using loop?

**URL:** https://forum.kirupa.com/t/how-to-shorten-this-code-using-loop/279152
**Category:** flash
**Created:** [January 10, 2009, 6:48am UTC](https://forum.kirupa.com/t/how-to-shorten-this-code-using-loop/279152 "2009-01-10T06:48:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ayumilove](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ayumilove/32/2532_2.png) [@ayumilove](https://forum.kirupa.com/u/ayumilove)
#### Post date: [January 10, 2009, 6:48am UTC](https://forum.kirupa.com/t/how-to-shorten-this-code-using-loop/279152/1 "2009-01-10T06:48:32Z")

</div>

Basically, I have few movieclip [all are same type] which is already on stage.  
Note: This movieclip is **not** added on stage using addChild  
In this movieclip, I have many movieclips, given with hex1…hex8 instance name

I wanted to do something like this  
hexArray = [hex1,hex2,hex3,hex4,hex5,hex6,hex7,hex8];  
and replace the code below with this… but it does not work.

```auto

for(var a:int = 0; a<9; a++){
for(var b:int = 0; b<8; b++){
	var colorFG1:ColorTransform = hcArray[a].hexArray**.miniHex.hexFG.transform.colorTransform;
}

```

```auto

	var colorFG1:ColorTransform = hcArray[a].hex1.miniHex.hexFG.transform.colorTransform;
	var colorFG2:ColorTransform = hcArray[a].hex2.miniHex.hexFG.transform.colorTransform;
	var colorFG3:ColorTransform = hcArray[a].hex3.miniHex.hexFG.transform.colorTransform;
	var colorFG4:ColorTransform = hcArray[a].hex4.miniHex.hexFG.transform.colorTransform;
	var colorFG5:ColorTransform = hcArray[a].hex5.miniHex.hexFG.transform.colorTransform;
	var colorFG6:ColorTransform = hcArray[a].hex6.miniHex.hexFG.transform.colorTransform;
	var colorFG7:ColorTransform = hcArray[a].hex7.miniHex.hexFG.transform.colorTransform;
	var colorFG8:ColorTransform = hcArray[a].hex8.miniHex.hexFG.transform.colorTransform;

```
