Skip navigation
logonsuresh
Currently Being Moderated

Cannot get more than 8 item in list component

Jun 22, 2012 9:05 AM

Hi,

 

I can't get more than 8 items in list component using getItemAt(), it returns null. I will search more for this but no result.

Please Help me here to move to next step.

 

Thanks

Sureshkumar G

 
Replies
  • Currently Being Moderated
    Jun 22, 2012 9:17 AM   in reply to logonsuresh

    Show the code that is giving you problems and explain the intentions of it.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 4:58 AM   in reply to logonsuresh

    I don't see how the second half of that code relates to the first half and you have not explained anything about it. 

     

    After the line:

     

    listDrop.dataProvider = dP;

     

    Whichever component you have that is named listDrop in that scope should have as many items in it as were provided by the data source.  Any code after that has no relationship to the listDrop component if it is in the same scope.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 6:31 AM   in reply to logonsuresh

    It appears they put the listDrop in _menuList as you see _menuList.listDrop.

     

    Here's a full example I just posted, slightly modified for this thread, of a list component being created, adding 50 items and selecting 2 items. Item #5 and #35. 35 is certainly past 8 so open a new as3 document and paste this in the frame script. If both traces work, the list component isn't your issue:

     

    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

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

    }

     

    It's probably the data you're inserting. Just try a trace() on the XML and make sure it's what you expect.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 24, 2012 7:58 AM   in reply to logonsuresh

    Show me the code you're using to disable the item. AFAIK you can't disable.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 24, 2012 5:03 PM   in reply to logonsuresh

    I believe you've found a glorified bug. I'd submit this to:

     

    https://bugbase.adobe.com/

     

    If I disable a visible item it works. If it isn't visible I get: TypeError: Error #1009: Cannot access a property or method of a null object reference.

     

    On my own list I did it to a currently visible item:

     

    CellRenderer(myList.itemToCellRenderer(myList.getItemAt(2))).enabled = false; // works fine

     

    I then did it to an item out of view:

     

    CellRenderer(myList.itemToCellRenderer(myList.getItemAt(35))).enabled = false; // error

     

    Even if I invalidateItemAt() that index to force a draw or make sure I drawNow() and add a 2 second wait to be absolutely sure the list is drawn and ready to be used, it errors.

     

    You could probably scroll to the item, disable, then scroll back where you were before, but that should be unnecessary.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 5:22 AM   in reply to logonsuresh

    If you're asking if you can overall, yes you can:

     

    http://help.adobe.com/en_US/as3/components/WS5b3ccc516d4fbf351e63e3d11 8a9c65b32-7f41.html

     

    If you're asking if you can do this in the same context, off-screen, no you still get the same error as the .enabled property.

     

    I hate to throw a hunch but I feel as though Adobe is employing something I'm used to in native iOS programming (Apple Devices). In lists they have something called "dequeue". It's the reason an extremely long list scrolls smoothly. What it does is render ONLY the rows that are in view. When a row is about to scroll off view it deallocates it from memory and then recreates the next row. They do this so you only ever have the current amount of viewable rows in memory and it speeds up scrolling. Although, I can make property changes to items in an iOS list that's off-screen so they don't have this issue ;(.  Just food for thought.

     

    I'd submit it to the bugbase and see what Adobe states. They may say they intend you to get the item in view, alter it and then go back to your previous position. That would be silly but at most I can tell you I definitely get errors trying to access an element outside my view. They're probably not used to items needing visual toggles when you can't even see them.

     

    edit:

     

    On a further note I tried the scrollToIndex() method, tried to disable, that much worked fine. The second I then scrolled back to the previously selected index the list screwed up.

     

    I even daisy chained functions a second apart (30 frames worth of wait). I scrolled down and that worked so I waited 1 second. I disabled the visible item I wanted to and that worked so I waited another second. I scrollToIndex(0) to get back to the top of the list, the list blew up. Random items (several items) were disabled and the one that I explicitly disabled was enabled.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points