listactionscript-3apache-flexflex4.5itemrenderer

Flex Mobile Access List value from itemRenderer


I have a list which is populated by list.dataProvider:

<fx:Script>
    <![CDATA[
        list.dataProvider = new ArrayCollection(getClass.listArticles(group, subgroup));
    ]]>
</fx:Script>

<s:List id="list" x="0" y="0" width="100%" height="100%" labelField="ArticleName" change="navigator.pushView(DetailView, list.selectedItem)">
    <s:itemRenderer>
        <fx:Component>
            <s:IconItemRenderer labelField="ArticleName"
                                messageField="EAN"/>
        <s:Image source="@Embed('assets/images/{EAN}.jpg')" width="70" height="70" horizontalCenter="0" verticalCenter="0" />
        </fx:Component>
    </s:itemRenderer>
    <s:layout>
        <s:TileLayout columnWidth="200" rowHeight="200" columnAlign="justifyUsingWidth" horizontalGap="10" orientation="rows" verticalGap="10"/>
    </s:layout>
</s:List>

labelField and messageField values are properly filled with the result of the dataProvider. The image source variable is not. How do I get/access this variable from the dataProvider ({EAN})?


Solution

  • Maybe by overriding set/get data?

            override public function set data(value:Object):void {
                super.data = value;
    
                if (!data)
                      return;
    
                img.source = data['EAN'];
                // or maybe: var xml:XML = data as XML; etc.
            }