PDA

View Full Version : display images from RemoteObject call


mantra
08-12-2008, 11:45 AM
Hi Guys,

only just getting into Flex 3 and have what seems probably an obvious problem. I've made a call to a ColdFusion CFC, which returns a query handled as an ArrayCollection containing directory data ( Name, Type etc ).

This all works fine, whenever i try to use the Name value though the image won't display. I have the images as a component within a Repeater.. Below is the code, hopefully someone can point out what i'm missing!

main.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="components.*">

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;

[Bindable]
public var qResult:ArrayCollection;

public function handleQueryResult(event:ResultEvent):void {
qResult = event.result as ArrayCollection;
trace(qResult.length);
}
]]>

</mx:Script>
<mx:RemoteObject id="myService" destination="ColdFusion" source="Snappy.images" showBusyCursor="true">
<mx:method name="sayHelloQuery" result="handleQueryResult(event)" fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>

<mx:Label id="lblStringResult" text="{qResult.getItemAt(0).Name}"/>
<mx:Button label="get String via Remote Object" click="myService.sayHelloQuery()" x="10" y="64"/>
<mx:DataGrid dataProvider="{qResult}" x="300" y="66"/>

<mx:Tile width="600" y="200">
<mx:Repeater id="iRepeater" dataProvider="{qResult}">
<comp:images imageData="{iRepeater.currentItem.Name}"/>
</mx:Repeater>
</mx:Tile>
</mx:Application>

The Image Component ( images.mxml )
<?xml version="1.0" encoding="utf-8"?>
<mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"
source="../images/{imageData}" trustContent="true">
<mx:Script>
<![CDATA[
[Bindable]
public var imageData:Object;
]]>
</mx:Script>
</mx:Image>

I should also point out when using the code as it is here, i do get little placeholder icons instead of the images. Is it a sandbox thing? The path is right.

Any help greatly appreciated !!