2 Replies Latest reply on Nov 3, 2011 6:42 PM by MobiSolo

    New to Flash Builder need help with AsyncListView

    MobiSolo

      Currently I have in my mobile application a list that has data being feed to it from an http service.  The list is coming up fine but the problem I am having is that I want to add an additional item to the list after the http service returns its data. I tried using the AsyncListView.addItem() and that seems to work but it eventually gets overwritten. It seems that binding the http data to the AsyncListView prevents me from further modifying the list since the list updates every time the http data changes.

       

      <s:AsyncListView list="{getTopCategoriesResult.lastResult}"  />

       

      The http service cannot be edited to add the additional item, the addition needs to come from within the program.

       

      Any help would be greatly appreciated.

       

      Thanks

        • 1. Re: New to Flash Builder need help with AsyncListView
          Amy Blankenship Level 4

          You'll need to add some separation and not jut dump your service's lastResult into the AsyncListView.  Instead, you'll need to have a proper responder function that catches the return and adds it to the AsyncListView.  The cool thing is, if you get this right, you can use the itemPendingError to automate getting the new items, and you can show the length of the expected collection (for instance, with a scroll bar), rather than just the items you already have.

           

          Check out http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/

          • 2. Re: New to Flash Builder need help with AsyncListView
            MobiSolo Level 1

            Hey Amy,

             

            Thanks so much for the response and I have been trying to make adding my current data provider to my AsynchViewList. This is what I have so far but it looks like I am still stuck.  The addItem function just does not seem to be working in the way that I am using it.  Here is some of my code, if any could help that would be awesome.

             

             

             

            var asyncToken:AsyncToken = topCategories.getTopCategories(my_module_object_id, object_id, data.id);  // <--- Data/Service Provider call.

            asyncToken.addResponder(new AsyncResponder(function result(event:ResultEvent, token:Object = null):void {

                for (var i:uint = 0; i < event.result.length; i++)

                {

                    theView.addItem(event.result[i]);

                }   

               

            }, function fault(event:FaultEvent, token:Object = null):void {

            }));

             

            ....

             

            <s:AsyncListView id="theView" />

             

             

            If you need more code or just more information in general let me know.

            Thanks again.