# Need help with MovieClip Loader and Passing Variables

**URL:** <https://forum.kirupa.com/t/need-help-with-movieclip-loader-and-passing-variables/313138>\
**Category:** flash\
**Created:** [August 21, 2010, 11:14am UTC](https://forum.kirupa.com/t/need-help-with-movieclip-loader-and-passing-variables/313138 "2010-08-21T11:14:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtingson](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mtingson](https://forum.kirupa.com/u/mtingson)\
**Post date:** [August 21, 2010, 11:14am UTC](https://forum.kirupa.com/t/need-help-with-movieclip-loader-and-passing-variables/313138/1 "2010-08-21T11:14:24Z")

</div>

Hi All,

I am having a problem with these code:

```php
myImages_mc = myGallery_mc.createEmptyMovieClip("myImages_mc", myGallery_mc.getNextHighestDepth());

var myMCL:MovieClipLoader = new MovieClipLoader();
var myPreloader:Object = new Object();
myMCL.addListener(myPreloader);

for (var i:Number=0; i<myImagesTotal; i++) {
        imageURL = myImages*.attributes.url;
        image_mc = myImages_mc.createEmptyMovieClip("mc"+i,myImages_mc.getNextHighestDepth());
        image_mc.main = i
        trace(image_mc.main); //traces correctly 0,1,2,3,4,etc.....
        
    
        image_mc._x = (Number(image_width)+Number(spacing))*i;
        myImages_mc["border_mc"+i]._x = (Number(image_width)+Number(spacing))*i;
        
        myMCL.loadClip(imageURL,image_mc);
    }
    
    myPreloader.onLoadComplete = function(target){
        target.onRelease = function(){
            trace(this.main) //traces undefined
        }
    }

```

The problem is everytime I click on the image\_mc, it traces “undefined”. I need to know the value of “image\_mc.main” when I click the image\_mc. The “main” variable should be the “i”, which is the number of loops. On the loop, it traces correctly, but when I put it on the onRelease function, it traces undefined.

Can you guys help me with these. I’m stuck here for almost a day.

Thanks!
