PDA

View Full Version : loop through and display images from remoteObject


mantra
09-26-2007, 01:49 PM
I've been trying to do this for a bit now and can't figure it out. I'll bet it's no doubt simple though ......

I'm using flx2 and cf - pulling image names and imageID from a database, returning them back as a returntype="query" from a CFC.

Whenever i try and put it within <mx:Image>, <mx:Tile> inside a <mx:Repeater> etc i can't specify which field to use for reference. ( as in the column holding the image name ). For a label and things like that you have either a labelField or a dataField ... How do you do it with an image ? and then repeat it

I'm using the following on the flx end to handle the returned data:

public function handleCfImgResult(event:ResultEvent):void {
sCfArticle = event.result as ArrayCollection;
}

Thx

mantra
09-28-2007, 01:19 AM
i figured this out, thought i'd put it up for anyone who's interested.

On the repeater element bind the ArrayCollection to it
<mx:Repeater id="myRep" dataprovider="{yourArrayCollection}">

Then within your image element, bind source down to the ArrayCollection's specific column holding the image info (name and/or path )along with currentItem (because you're in the repeater, so currentItem will increment)

<mx:Image source="http://localhost/directory/image/{myRep.currentItem.thumbnail}"/>

pretty straight-forward as i initially thought, just wasn't thinking i spose. The full code is along the lines of:

<mx:Tile>
<mx:Repeater id="myRep" dataprovider="{yourArrayCollection}">
<mx:Image source="http://localhost/directory/image/{myRep.currentItem.thumbnail}"/>
</mx:Repeater>

</mx:Tile>