I am trying to dynamically load an Image is a DataGridColumn. The
data for my DataGrid comes from a xml file loaded from a HttpService.
The xml file has a type attribute that I would like to use some
ActionScript to evaluate and dynamically load an Image based on the
data in the attribute.
I have my code almost working. The problem is that I can only get it
to work with two choices, but there are more then that.
Any ideas?
Here is the code that works:
<mx:DataGridColumn headerText="gender"
width="80">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="[EMAIL PROTECTED] == 'm' ?
'assets/images/largeMaleCust01.png' :
'assets/images/largeFemCust01.png' }" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
I want to do something like this:
<mx:DataGridColumn headerText="gender"
width="80">
<mx:itemRenderer>
<mx:Component>
<mx:Image
source="{
if ([EMAIL PROTECTED] == 'm') {
'assets/images/largeMaleCust01.png'
} else if ([EMAIL PROTECTED] == 'f') {
'assets/images/largeFemCust01.png'
} else {
'assets/images/largeCustomer01.png'
}" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
The problem is obviously related to all the curly braces, but I don't
know how to implement this. I'd love to extract this logic into an
ActionScript function, but can't figure it out.
Thanks for any and all help.
Erik Weibust