Preloader wont disappear after MovieClipLoader determines load complete

I cant seem to make my preloader disappear after the MovieClipLoader class has determined the load is complete. I have a movieclip I attach onto the stage called thumbnailModule_mc inside of it I have the preloader movieclip (a simple spinning circle) and the image holder movieclip that the MovieClipLoader is listening to see when the image load is complete. When the load completes I want to set the alpha to zero and fade in the image. But my code doesn’t work! the preloader stays visible. I cant figure out what is wrong.

Here is my code:


function loadHomeBar(xmlFileName:String) {
var homeSideBar:XML = new XML();
homeSideBar.ignoreWhite = true; 
        
homeSideBar.onLoad = function (success) {
        
    if (success) {
        var root:XMLNode = this.firstChild;
        for (i = 0; i < root.childNodes.length; i++) {
            
        var titleItem:String = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue; 
        var imgItem = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue; 
        linkItem.push (this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue);
        
        var thumbLoader:MovieClipLoader = new MovieClipLoader();
        var thumbListener:Object = new Object();
        thumbLoader.addListener(thumbListener);
        
        sideBar_mc.thumbnailsHolder_mc.attachMovie("thumbnailModule_mc", "thumbnailModule_mc"+i,i);
        if (i ==0){ 
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i]._y = 0; 
            } else {
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i]._y = i * 102; 
            } 
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].thumbnailTitle_mc.title_txt.text = titleItem;
                
        thumbListener.onLoadInit = function (target) {
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].circlepreloader_mc._alpha = 100;
        }
        
        thumbListener.onLoadProgress = function(target, bytesLoaded, bytesTotal) {
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].circlepreloader_mc._alpha = 100;
            trace("loading");
        }
        
        thumbListener.onLoadComplete= function(target) { 
            sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].circlepreloader_mc._alpha = 0;
            trace("complete");
        }
        
        thumbLoader.loadClip(imgItem, sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].imgHolder_mc);      
                
        sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].hit_btn.ID = i; 
        sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].hit_btn.onRollOver = function() {
            
            this._parent.overlay_mc.tween("_x", 245, .25, "easeOutQuad");
            this._parent.thumbnailTitle_mc.tween("_x", 240, .25, "easeOutQuad");
            this._parent.gotoAndPlay("over");
        }
    
        sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].hit_btn.onRollOut = function() {
        
            this._parent.overlay_mc.tween("_x", 1, .25, "easeOutQuad");
            this._parent.thumbnailTitle_mc.tween("_x", 1, .25, "easeOutQuad");
            this._parent.gotoAndPlay("out");
        }
        
        sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].hit_btn.onRelease = function() {
            var btnInstance:Number = this.ID; 
            //the variable btnInstance is then used at the index
            trace(linkItem[btnInstance]);
        }
                
        checkScroll(sideBar_mc.scrollBar_mc,sideBar_mc.thumbnailsHolder_mc,Stage.height);

        }
    }
}
homeSideBar.load (xmlFileName);
}
loadHomeBar("xml/sidebar_home.xml");

Rather than tracing “complete” when it’s done, can you trace out “sideBar_mc.thumbnailsHolder_mc["thumbnailModule_mc" + i].circlepreloader_mc” so you can see that you’re accessing the MC correctly?

@ferrari_chris
I tried to trace the actual instance name like you said and it kept tracing undefined. So I then entered an actual instance name of one of the clips that gets attached to the stage when the for loop completes:

My example using the test clips instance name:


thumbListener.onLoadComplete= function(target) { 
sideBar_mc.thumbnailsHolder_mc.thumbnailModule_mc0.circlepreloader_mc._alpha = 0;
        }

And what happens is that it does make the preloader for the first movieclip in my for loop disappear. But I dont know how to apply it so that it will work with all the other clips. So I’m still stuck :confused:

So, as you can see, you’re not accessing that MC correctly.

Somewhere, likely in the thumbnailsHolder_mc["thumbnailModule_mc" + i] part, something is incorrect which is not letting you address the MC you want.

As you know the effect you want does work, you just need to figure out how you can target the MC properly.

Yes, I’m aware that using thumbnailsHolder_mc[“thumbnailModule_mc” + i] isn’t a way to target it the clip properly. I’m look for a way to properly target it within my already established for loop. Anyone with ideas on how to do it?

Try this and see if you have any luck:

eval("sideBar_mc.thumbnailsHolder_mc[thumbnailModule_mc" + i + "].circlepreloader_mc")._alpha = 0;

Gave eval a shot it didn’t work either. Since it’s clearly the way I target the instance name I’m starting to think I need to add a variable that increments by one each time the loop runs then some how tie that to the way I write the instance name of the targeted clip.