Flash AS3: position loaded images from loop based on image height

Posted by HeroicNate on Stack Overflow See other posts from Stack Overflow or by HeroicNate
Published on 2010-06-10T05:29:21Z Indexed on 2010/06/10 5:32 UTC
Read the original article Hit count: 227

I'm trying to dynamically stack images that are being pulled in via an xml file. Below is what I'm doing, and it almost works. The problem is that it only seems to fire off the event complete function on the very last one, instead of going for all of them. Is there a way to make it run the even.complete function for each image?

function aboutfileLoaded(event:Event):void {
    aboutXML = new XML(aboutTextLoader.data);
for(var l:int = 0; l < aboutXML.aboutimages.image.length(); l++)
    {
            imageLoader = new Loader();
            imageSource = aboutXML.aboutimages.image[l];

            if (imageSource != "") {
                    this.imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, aboutimageLoaded);
                    this.imageLoader.load(new URLRequest(imageSource));

                    //aboutBox.aboutContent.addChild(imageLoader);
                    //imageLoader.y = imageYpos;
                    //imageYpos = imageYpos + 50;
            }

    }
}

function aboutimageLoaded(event:Event):void {
            aboutBox.aboutContent.addChild(imageLoader);
            this.imageLoader.y = imageYpos;
            imageYpos = imageYpos + this.imageLoader.height;
}

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about loop