I am facing a particular problem which I am unable to resolve. I am using ActionScript 3 with Robotlegs framework. I have to make a series of URL Requests in a command. Each URL gives an image. I am pushing these images into an ArrayCollection and then dispatching an event with this ArrayCollection as the payload. This ArrayCollection is sent to a view which uses an itemRenderer to display the images. I have checked that images are being loaded to the ArrayCollection but the images are not being displayed in the view.
This is what I have written in the command,
var arrayCollect:ArrayCollection = new ArrayCollection();
var my_loader:Loader = new Loader();
my_loader.load( new URLRequest( "http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg" ) );
arrayCollect.addItem(my_loader as Object );
my_loader.load( new URLRequest( "http://www.joomlaworks.net/images/demos/galleries/abstract/8.jpg" ) );
arrayCollect.addItem(my_loader as Object );
return arrayCollect;
Then the arrayCollect is being dispatched in a event as payload.
dispatch( new XYZEvent ( XYZEvent.LOAD_COMPLETE, arrayCollect ) );
In the view, I used an itemRenderer.
<s:List id="pqr"
dataProvider="{data}">
....
</s:List>
The images are not being displayed. I think the problem is that the data in the arrayCollection are objects of type 'loader'. So I tried to typecast it as a BitmapImage, but it did not resolve the issue.
Please help me resolve this.
Your problem is you didn't define a item renderer which could show your data. See http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WS03d33b8076db57b9-23c04461124bbeca597-8000.html for creating custum itemrenderers.
Next: in your ArrayCollection you didn't create a new Loader. Meaning the ArrayCollection item 1 is pointing to the same laoder is item 2.
I added an example with 2 lists, one without a renderer an one with a custum renderer. I didn't use the loaders, but of course you could create a renderer which add a laoder to teh display instead of using a Flex image component.
Main application:
Renderer
If you realy want to use a laoder as object in your ArrayCollection, you could write your renderer as: