Preload images one after another from xml-file

Hi everyone,

I’m new to this forum, so I will shortly introduce myself before asking silly questions. :pope: I work as a consultant for a content-management company. At the moment i am working on a private flash gallery. the plan is to have an xml file with configuration-stuff and information such as paths, filenames etc. and to load this into a movie. The I figured out to load the xml file and to load the picture. The thing I really don’t get is to load the picture one after another, and not all at the same time into the movie. Is there a function like: donLoadaPictureUntilThisOneIsntReady()? :wink:

Here is what I have:


// Listeners
loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
    loadComplete = true;
    trace("Size for "+target_mc._name+" W: "+target_mc._width+" H: "+target_mc._height);;
    trace(">> loadListener.onLoadComplete()");
}

loadListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
    trace(target_mc + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal); 
}

loadListener.onLoadInit = function(target_mc:MovieClip):Void {
    loadComplete = false;
    target_mc._x = marginValue + int(borderwidth) + ((picFrameWidth - marginValue - int(borderwidth) - target_mc._width) / 2);
    target_mc._y = Math.round((docHeight - target_mc._height) / 2);
}

// Iterate and count images
for (var aNode:XMLNode = galleryConfig.firstChild.firstChild; aNode != null; aNode = aNode.nextSibling) {

    if (aNode.nodeName == "IMAGE") {
        imagePath = aNode.firstChild.firstChild.nodeValue;
        imageDescription = aNode.lastChild.firstChild.nodeValue;
        _root.createEmptyMovieClip("image"+imageCount, imageCount);
        var mcLoader:MovieClipLoader = new MovieClipLoader();

        mcLoader.addListener(loadListener);
        mcLoader.loadClip(imagePath,_level0["image"+imageCount]);

        _level0["image"+imageCount]._alpha = 5;
        trace("Created MovieClip image"+imageCount);
        imageCount++;
    }
}
trace(imageCount+" pictures found");

Thanks for any help. I’m really going mad about this.

Zep

[QUOTE=Zep;1983876]Hi everyone,

I’m new to this forum, so I will shortly introduce myself before asking silly questions. :pope: I work as a consultant for a content-management company. At the moment i am working on a private flash gallery. the plan is to have an xml file with configuration-stuff and information such as paths, filenames etc. and to load this into a movie. The I figured out to load the xml file and to load the picture. The thing I really don’t get is to load the picture one after another, and not all at the same time into the movie. Is there a function like: donLoadaPictureUntilThisOneIsntReady()? :wink:

Here is what I have:


// Listeners
loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
    loadComplete = true;
    trace("Size for "+target_mc._name+" W: "+target_mc._width+" H: "+target_mc._height);;
    trace(">> loadListener.onLoadComplete()");
}

loadListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
    trace(target_mc + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal); 
}

loadListener.onLoadInit = function(target_mc:MovieClip):Void {
    loadComplete = false;
    target_mc._x = marginValue + int(borderwidth) + ((picFrameWidth - marginValue - int(borderwidth) - target_mc._width) / 2);
    target_mc._y = Math.round((docHeight - target_mc._height) / 2);
}

// Iterate and count images
for (var aNode:XMLNode = galleryConfig.firstChild.firstChild; aNode != null; aNode = aNode.nextSibling) {

    if (aNode.nodeName == "IMAGE") {
        imagePath = aNode.firstChild.firstChild.nodeValue;
        imageDescription = aNode.lastChild.firstChild.nodeValue;
        _root.createEmptyMovieClip("image"+imageCount, imageCount);
        var mcLoader:MovieClipLoader = new MovieClipLoader();

        mcLoader.addListener(loadListener);
        mcLoader.loadClip(imagePath,_level0["image"+imageCount]);

        _level0["image"+imageCount]._alpha = 5;
        trace("Created MovieClip image"+imageCount);
        imageCount++;
    }
}
trace(imageCount+" pictures found");

Thanks for any help. I’m really going mad about this.

Zep[/QUOTE]
This may help

#10

or/