views:

5

answers:

1

Hi All,

I am trying to build a simple preloader. I have 4 movieclips on stage and on each one i am adding an image that comes from an xml file

theMap = new XML();
theMap.ignoreWhite = true;

theMap.onLoad = function(success){
    if (success) {
        theNodes = theMap.firstChild.childNodes;
        for (i=0;i < theNodes.length;i++) {
            theSrc      = theNodes[i].attributes.src; //the jpg
            theClip     = theNodes[i].attributes.clip; //the movieclip
            _root[theClip].loadMovie(theSrc); // adding the jpg to the movieclip
        }
    }
    else {
        trace('Cannot Load XML file.');
    }
}
theMap.load("map.xml");

everything works ok but as the jpgs are a bit heavy i'd like to preload them. Is that possible?

A: 
        var mcLoader:MovieClipLoader = new MovieClipLoader();
        mcLoader.addListener(this);
        this.onLoadProgress = function(target_mc:MovieClip,bytesLoaded:Number,bytesTotal:Number){
            var percentage:Number = int(bytesLoaded/bytesTotal*100);
            trace(percentage);
            if (percentage >= 100) { _root.waiting._visible = false; }
        }

        mcLoader.loadClip(theSrc,theClip);
tsiger