Search code examples
actionscript-3apache-flexactionscriptairiconitemrenderer

Adobe Air - Load PNG image from file in IconItemRenderer


I have a LIST object that has an IconItemRenderer. I have images stored in the documentsDirectory and would like to dynamically attach them to items in the list based on a proptery in the "item" in the iconFunction.

I've looked everywhere for an iconFunction that will return an image from file.


Solution

  • <s:List width="150">
      <s:itemrenderer>
        <fx:component>
            <s:Image source="{data.img}"/>
        </fx:component>
      <s:itemrenderer>
    </s:List>
    

    here in 'data.img' img is the property which holds the path to the image. This data object is also available in your itemrenderer file. so you can use as below in your iconItemrenderer

    <s:Image source="{data.img}"/>
    

    Even if you dont have path and have byteArray instead of path of image, you can pass the same to source property

    Ex : <s:Image source="{data.byteArray}"/>