# Simple for loop help

**URL:** <https://forum.kirupa.com/t/simple-for-loop-help/221649>\
**Category:** flash\
**Created:** [April 5, 2007, 11:20pm UTC](https://forum.kirupa.com/t/simple-for-loop-help/221649 "2007-04-05T23:20:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ad0ac](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@ad0ac](https://forum.kirupa.com/u/ad0ac)\
**Post date:** [April 5, 2007, 11:20pm UTC](https://forum.kirupa.com/t/simple-for-loop-help/221649/1 "2007-04-05T23:20:36Z")

</div>

I’ve been experimenting with a simple imageViewer class, implemented like this:

var viewer1:thumbLoader = new thumbLoader(target\_mc);  
viewer1.loadImage(“whatever.jpg”);

my question is how would i use a for loop to make twenty viewers (1-20) load say, twenty elements from an array. One problem is that if I use a string like [“viewer” + i], the class file is expecting a movieclip and throws up a type mismatch. I would guess it’s done something like this:

for (var i=0; i\<20; i++) {  
var this[“viewer”+i]:Thumbloader = new thumbLoader(“target\_mc”+i);  
}  
but obviously this doesn’t work. any help much appreciated.
