# Preload images one after another from xml-file

**URL:** <https://forum.kirupa.com/t/preload-images-one-after-another-from-xml-file/204826>\
**Category:** Uncategorized\
**Created:** [October 23, 2006, 8:55pm UTC](https://forum.kirupa.com/t/preload-images-one-after-another-from-xml-file/204826 "2006-10-23T20:55:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zep](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zep/32/2941_2.png) [@Zep](https://forum.kirupa.com/u/Zep)\
**Post date:** [October 23, 2006, 8:55pm UTC](https://forum.kirupa.com/t/preload-images-one-after-another-from-xml-file/204826/1 "2006-10-23T20:55:34Z")

</div>

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()? 😉

Here is what I have:

```auto

// 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

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 23, 2006, 9:46pm UTC](https://forum.kirupa.com/t/preload-images-one-after-another-from-xml-file/204826/2 "2006-10-23T21:46:32Z")

</div>

[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()? 😉

Here is what I have:

```auto

// 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

> **[kirupaForum](https://forum.kirupa.com)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

#10

or/

> **[kirupaForum](https://forum.kirupa.com)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!
