So Joan was kind enough to help me use data from a DataGrid
cell, and conditionally display an image that matched the cell
data. That worked great, but now I've got a further issue.
Completely outside the datacell, I have a list of properties,
which show values based on the row selected in the grid (a detail
view as it were). Here again I have the same issue, where I need to
display 1 of 6 images depending on the value of a variable for the
object selected in the DataGrid.
In the previous example, the solution was to override the set
data method, but that won't work in this instance because the item
isn't a DataGrid that supports that. Any thoughts on how I should
be approaching this?
I assume that your data used in the DataGrid has a field to
indicate the image. Let's say it is called "image". When the row is
selected a change event is dispatched (or you can use itemClick).
The DataGrid's selectedItem will be the record with the image field
If you have <mx:Image id="showHere" width="640"
Then in the DataGrid event handler you can do:
showHere.source = event.target.selectedItem.image;
If you do not have <mx:Image> but have your own
component, then using data is again a viable way to go: