# Path problem in loop

**URL:** <https://forum.kirupa.com/t/path-problem-in-loop/256867>\
**Category:** Uncategorized\
**Created:** [April 8, 2008, 7:53am UTC](https://forum.kirupa.com/t/path-problem-in-loop/256867 "2008-04-08T07:53:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neznanec](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@neznanec](https://forum.kirupa.com/u/neznanec)\
**Post date:** [April 8, 2008, 7:53am UTC](https://forum.kirupa.com/t/path-problem-in-loop/256867/1 "2008-04-08T07:53:38Z")

</div>

I have three movie clips on stage that I want to fill with dynamically loaded jpegs and then resize jpegs so they fit the movie clips.

This is what I came up with:

```auto

var maxWidth = 150;
var maxHeight = 100;
var i:Number;
for (i = 1; i < 4; i++) {
    var container = "button"+i+".emptyMC"
    var thumbloader = new MovieClipLoader();
    thumbloader.loadClip("img"+i+".jpg",container);
    thumbloader.onLoadInit = function(ctnr:MovieClip, i:Number) {
        trace([COLOR=Black]container[/COLOR]);
        if ([COLOR=DarkRed]container[/COLOR]._width>=200) {
            var ctnrWidth = [COLOR=DarkRed]container[/COLOR]._width;
            scalePercent = (ctnrWidth>maxWidth) ? maxWidth*100/ctnrWidth : scalePercent;
            [COLOR=DarkRed]container[/COLOR]._xscale = scalePercent;
        }
        if ([COLOR=DarkRed]container[/COLOR]._height>=100) {
            var ctnrHeight = [COLOR=DarkRed]container[/COLOR]._height;
            scalePercent = (ctnrHeight>maxHeight) ? maxHeight*100/ctnrHeight : scalePercent;
            [COLOR=DarkRed]container[/COLOR]._yscale = scalePercent;
        }
    };
}

```

It attaches pictures like it should only the resizing part doesnt work. The value of container is stuck with “button3.emptyMC” and the only way I can get this code to work is if I change everything that is in red with actual path (button1.emptyMC).

What am I doing wrong?

Thanks
