0

I'm loading images using XML. Right now, the situation is that the image is only loaded onto the last entry in the XML. cv is a popup that contains a holder called cHolder and a text field called ct. The images will be loaded onto cHolder. How do is solve this so that image will loaded onto all cHolder?

for each (var projectName:XML in projectAttributes) 
    {
        //trace(projectName);
        var projectDP:XMLList = projectInput.project.(@name == projectName).displayP;
        trace(projectDP);

        var cv:MovieClip = new cView();
        catNo += 1;
        if(catNo % 5 == 0)
        {
            catY += 137;
            catX = -170;
            cv.x = catX;
            cv.y = catY;
        }
        else
        {
            cv.x = catX;
            cv.y = catY;
            catX += 112;
        }

        imageLoader.load(new URLRequest(projectDP));        
        cv.cHolder.addChild(imageLoader);
        cv.ct.text = projectName;
        cv.buttonMode = true;
        this.addChild(cv);
    }

2 Answers 2

1

you need to use a separate loader object for each image. Something like this:

for each (var projectName:XML in projectAttributes) {
    ...
    imageLoader = new Loader();
    imageLoader.load(new URLRequest(projectDP));
    ...
}

Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

0

I would highly recommend LoaderMax (http://www.greensock.com/loadermax/) Its fantastic for loading multiple items.

A sample would be:

var queue:LoaderMax = new LoaderMax({onComplete:onComplete});

queue.append(new ImageLoader("img/photo1.jpg", {name:"photo1"}));
queue.append(new ImageLoader("img/photo2.jpg", {name:"photo2"}));
queue.append(new ImageLoader("img/photo3.jpg", {name:"photo3"}));
queue.append(new ImageLoader("img/photo4.jpg", {name:"photo4"}));

queue.load();

function onComplete() {
  trace("All done");
  cv.cHolder.addChild(queue.getContent("myPhoto1")); // etc
}

You could use array's etc to store the references etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.