# Include dynamic name in variables?

**URL:** https://forum.kirupa.com/t/include-dynamic-name-in-variables/291277
**Category:** flash
**Created:** [June 27, 2009, 3:56am UTC](https://forum.kirupa.com/t/include-dynamic-name-in-variables/291277 "2009-06-27T03:56:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![spmckee](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@spmckee](https://forum.kirupa.com/u/spmckee)
#### Post date: [June 27, 2009, 3:56am UTC](https://forum.kirupa.com/t/include-dynamic-name-in-variables/291277/1 "2009-06-27T03:56:28Z")

</div>

Greetings,

I am trying to loop through several lines of code and replace certain parts of the variables with a number in a loop. You can see what I have here:

```auto
            for (var j:int=0; j <= bootArray.length; j++) {
                switch (j) {
                    case 1 :
                        bootBtnMC1.visible = true;
                        var imgPath1="_assets/img/ALII/ALII_" + bootArray[0] + "_thumb.png";
                        var loader1:Loader=new Loader;
                        var request1:URLRequest=new URLRequest(imgPath1);
                        loader1.load(request1);
                        MovieClip(root).bootBtnMC1.thumbImgMC.addChild(loader1);
                        break;

                    case 2 :
                        bootBtnMC2.visible = true;
                        var imgPath2="_assets/img/ALII/ALII_" + bootArray[1] + "_thumb.png";
                        var loader2:Loader=new Loader;
                        var request2:URLRequest=new URLRequest(imgPath2);
                        loader2.load(request2);
                        MovieClip(root).bootBtnMC2.thumbImgMC.addChild(loader2);
                        break;

```

Is there a way I can trim this down? I have these cases through 7. It works the way I have it but it’s obviously very poor coding. I know how to do it in AS2 but I just keep getting error after error in AS3.

Thanka a ton!  
SP
