title: IconItemRender In Flex 4.5.1 With Dynamically Called Icon
body: <p>Alright, simple item render, or so I thought... I have an some data loaded into a list, one of the fields is project_Type. It's a string that either says "RESIDENTIAL" or "COMMERCIAL". And based on that string, I just want to display a little house, or a little office building as the icon. So, I cobbled together my itemrender as follows:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:IconItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      labelField="dateAdded" 
                      messageField="builder_Name" 
                      iconFunction="myiconfunction"
                      iconWidth="48" iconHeight="48"
                      decorator="@Embed('assets/Right-48x48.png')" &gt;
  
      &lt;fx:Script&gt;
          &lt;![CDATA[
  
      //  iconFunction="myiconfunction"
      //  iconWidth="32" iconHeight="32" --&gt;
  
              private function myiconfunction(data:Object):String{
  
                  var type:String; 
  
                  var projectType:String = (data != null) ? data.project_Type : "QUESTION";
  
                  if (projectType == "RESIDENTIAL") { 
                      type = "assets/House-48x48.png";
                  } 
                  else if (projectType == "COMMERCIAL") { 
                      type = "assets/Commercial-48x48.png";
                  } 
  
                  else if (projectType == "QUESTION") {
                      type = "assets/Question-48x48.png";
                  }
  
                  return type;
  
              }  
  
          ]]&gt;
      &lt;/fx:Script&gt;
  
  &lt;/s:IconItemRenderer&gt;
  </code></pre>
  
  <p>So, pretty straight forward there... But know custom icon.... No errors either though. What am I doing wrong guys?</p>
  
  <p><em><strong>Update</em></strong></p>
  
  <p>So, I changed the item renderer to the following, and still no icon... I've double checked the data and RESIDENTIAL and COMMERCIAL are both being passed...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:IconItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      labelField="dateAdded" 
                      messageField="builder_Name" 
                      iconFunction="myiconfunction"
                      iconWidth="48" iconHeight="48"
                      decorator="@Embed('assets/Right-48x48.png')" &gt;
  
      &lt;fx:Script&gt;
          &lt;![CDATA[
  
              [Embed(source="assets/House-48x48.png")]
              public var residentialClass:Class;
  
              [Embed(source="assets/Commercial-48x48.png")]
              public var commercialClass:Class;
  
              [Embed(source="assets/Question-48x48.png")]
              public var questionClass:Class;
  
              private function myiconfunction(data:Object):Object
              {
  
              var projectType:String = (data != null) ? data.project_Type : "QUESTION";
  
              if (projectType == "RESIDENTIAL") { 
                  return residentialClass;
              } 
              else if (projectType == "COMMERCIAL") { 
                  return commercialClass;
              } 
  
              return questionClass;
  
              }  
  
          ]]&gt;
      &lt;/fx:Script&gt;
  
  &lt;/s:IconItemRenderer&gt;
  </code></pre>
  
  <p>But alas, nothing...</p>