1 Reply Latest reply: Jun 23, 2012 6:21 AM by sinious RSS

    list.getItemAt issue - not working out of height or row count range

    logonsuresh Community Member

      List.getItem is working based upon the list height or rowCount. Out of range is not working.

      Any body have any idea to clear this?

       

      Thanks

      Sureshkumar G

        • 1. Re: list.getItemAt issue - not working out of height or row count range
          sinious MVP

          Can you elaborate more? Out of range is working perfectly fine for me. Full example:

           

          import fl.controls.List;

          import fl.data.DataProvider;

          import flash.events.Event;

           

          // make a quick dataprovider with 50 items

          var dp:DataProvider = new DataProvider();

          for (var i:int = 0; i < 50; i++)

          {

                    dp.addItem({label:"item "+i,value:i});

          }

           

          // make list control

          var myList:List = new List();

          addChild(myList);

          myList.setSize(100,300);

          myList.dataProvider = dp;

           

          // wait for frame to be drawn before accessing

          addEventListener(Event.ENTER_FRAME, handleAddedToStage);

           

          function handleAddedToStage(e:Event):void

          {

                    removeEventListener(Event.ENTER_FRAME, handleAddedToStage);

           

                    // traces item 5

                    trace("Item: " + myList.getItemAt(5).label);

           

                    // traces item 35, despite out of view

                    trace("Item: " + myList.getItemAt(35).label);

           

                    try

                    {

                              trace("Item: " + myList.getItemAt(95).label);

                    }

                    catch (e:RangeError)

                    {

                              // traces out, value out of range

                              trace("Out of range");

                    }

          }