1 Reply Latest reply: Oct 9, 2013 5:00 PM by Chris Velevitch RSS

    Undefined property data in inline itemrenderer

    Chris Velevitch MeganK

      I get:-

       

      1120: Access of undefined property data.

      in the following code:-

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                          xmlns:s="library://ns.adobe.com/flex/spark"

                          title="HomeView">

       

      <fx:Script>

                          <![CDATA[

                                    import mx.collections.ArrayCollection;

       

                                    [Bindable]

                                    private var imageList:ArrayCollection;

                          ]]>

      </fx:Script>

       

                <s:List dataProvider="{imageList}" width="100%" height="100%">

        <s:layout>

        <s:TileLayout/>

        </s:layout>

        <s:itemRenderer>

        <fx:Component>

                    <s:BitmapImage source="{data.image}" width="150" height="150"/> <!-- HERE -->

        </fx:Component>

        </s:itemRenderer>

      </s:List>

       

      </s:View>

       

       

      I'm using Flex 4.10 but I tried against 4.6 and I still get this error.

       

      I've no problems before in creating inline item renderers, so what am I missing here?

        • 1. Re: Undefined property data in inline itemrenderer
          Chris Velevitch MeganK

          I'm answering my own question.

           

          There is a difference between mx and spark when creating inline item renderers. To create a spark inline item renderer, you need to extend an item renderer class:-

           

          <s:List dataProvider="{imageList}" width="100%" height="100%">

               <s:layout>

                    <s:TileLayout/>

               </s:layout>

              <s:itemRenderer>

                   <fx:Component>

                        <s:ItemRenderer>

                             <s:BitmapImage source="{data.image}" width="150" height="150"/>

                         </s:ItemRenderer>

                    </fx:Component>

                 </s:itemRenderer>

          </s:List>

          I suspect this is due to the mx components being designed by the kitchen sink approach, where as the spark components has eliminated all the unneccessary bloat.