# Getting images from an xml and into seperate MovieClips/Sprites

**URL:** <https://forum.kirupa.com/t/getting-images-from-an-xml-and-into-seperate-movieclips-sprites/250866>\
**Category:** flash\
**Created:** [February 2, 2008, 1:21pm UTC](https://forum.kirupa.com/t/getting-images-from-an-xml-and-into-seperate-movieclips-sprites/250866 "2008-02-02T13:21:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blekk](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@Blekk](https://forum.kirupa.com/u/Blekk)\
**Post date:** [February 2, 2008, 1:21pm UTC](https://forum.kirupa.com/t/getting-images-from-an-xml-and-into-seperate-movieclips-sprites/250866/1 "2008-02-02T13:21:06Z")

</div>

Hello, I have a bit of a problem.

I have started on an AS file to get images from an XML document and then add them to separate movieclips (or any other bitmap holder) so that I can then manipulate them separately.

My problem is that I cannot get them into seperate movieclips, I don’t know which way to go about it. For example, once I have got the urls to the images from the XML file, I put them into an array using a for(){} loop, but after that I don’t know how to put them into seperate movieclips or sprites.

Here is the function that puts the urls into an array:

```auto
public function loadImage(xml:XML)
        {                    
             var btnLoader:Loader = new Loader();
            _btnArray.length = 3;
            for(var i = 0;i<3;i++)
            {
                _btnArray* = xml.child("btn").attribute("href")*;
                trace(_btnArray*);
            }
         }

```

I tried creating a new movieclip inside the for loop and adding the image to it:

```auto
btnLoader.load(new URLRequest(_btnArray*));
                var btn:MovieClip = new MovieClip();
                btn.addChild(btnLoader);

```

But this obviously meant, for each time, the new image was being loaded into the same MovieClip called “btn”. Therefore I could not manipulate the images separately.

My question is; How do I add the images to separate MovieClips or Sprites etc?

Thanks for your time,

Blekk.
