tags:

views:

31

answers:

1

Hi there, i can't download more then one image from url

function processXML(e:ResultEvent):void 
    {
        myXML = e.result as XML;
        for (var i:Number=0;i<myXML.icon.length();i++)//amout of urls.Now there tree elements
           {
              loader.load( new URLRequest(myXML.image[i].imageURL.toString()));   //get url             
           }
    }

there is event.COMPLETE function

private function handleLoadComplete( e:Event ):void

           {


              var bmp:Bitmap = ( e.target as LoaderInfo ).content as Bitmap;
           imgColl.addItem(bmp); //sore elements
           Alert.show("load complete");//scheck for loadin
           img.source = imgColl.getItemAt(1) as Bitmap; // ERROR Store only one element

MXML file

<mx:Image id="img" width="20" height="20"/> 

What i'm doing wrong?

+1  A: 

You need to use separate loaders for each concurrent request.

It's not explicitly clear from the docs, but it does say this:

The Loader class overrides the following methods that it inherits, because a Loader object can only have one child display object—the display object that it loads. Calling the following methods throws an exception: addChild(), addChildAt(), removeChild(), removeChildAt(), and setChildIndex(). To remove a loaded display object, you must remove the Loader object from its parent DisplayObjectContainer child array.

Sam