3 Replies Latest reply on Apr 16, 2010 10:29 AM by Shongrunden

    Spark HList ItemRenderer

    daslicht Level 2


      I have a external ItemRenderer for a Spark List which displays only one Item.


      How do I get that Item and its including data.


      At the moment I use getChildAt and Cast it as a Instance of the Item Renderer.



      var temp:HListRenderer = myList.getChildAt( myList.selectedIndex ) as HListRenderer;
          temp.varToAccess = 'cool';


      Is there a smarter way to do this ?

      How to access the visible Item of a <s:HList/> ? In that case I could negelect the whole get ChildAt approach.




        • 1. Re: Spark HList ItemRenderer
          David_F57 Level 5



          there is this mylist.dataGroup.getItemIndicesInView() - saw this in an earlier post that shongrunden(adobe) answered.


          I know there is a call to get the first and last items in a view but for the life of me I can't find it, I might have to pester one of the Adobe guys



          • 2. Re: Spark HList ItemRenderer
            Flex harUI Adobe Employee

            The layout should have a firstIndexInView and lastIndexInView

            • 3. Re: Spark HList ItemRenderer
              Shongrunden Adobe Employee

              Here is a sample application based on the sample provided in http://forums.adobe.com/message/2731455

              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                          public function getData():void {
                               var indicesInView:Vector.<int> = list1.dataGroup.getItemIndicesInView();
                               for (var i:int = 0; i < indicesInView.length; i++){
                                  var dataItem:* = list1.dataProvider.getItemAt(indicesInView[i]);
                                  trace('data at index ', indicesInView[i], ' = ', dataItem);
                      <s:Button label="increment vsp" click="list1.dataGroup.verticalScrollPosition+=22" />
                      <s:Button label="trace data of items in view" click="getData()" />
                  <s:List id="list1" width="100" height="18">