6 Replies Latest reply on Jan 13, 2009 2:41 PM by Jed Schneider

    ArrayCollection vs. XMLListCollection

    Jed Schneider Level 1
      As I understand it, and I can't remember where I ready it, an itemrenderer is reused and so the flex app is only displaying images for the visible items in the list component, plus a couple extra for scrolling purposes. Well, what if you literally have hundreds of images and want to create a very smooth scrolling experience?

      I am currently accessing the source of the image for the itemrederer through an xmllistcollection in e4x format.
      I read somewhere else that there is a speed consideration when choosing to use an xmllistcollection versus an arraycollection. is this true, if so, is it possible that moving to an ArrayCollection would solve the load times, eg, it is implicit with the ArrayCollection data structure that the data is more quickly accessible?

      Finally, is it possible to preload or specify how many images are loaded into the itemrederers before the app recycles them?

      thanks guys,

      jed

        • 1. Re: ArrayCollection vs. XMLListCollection
          rtalton Level 4
          You're correct re: itemrenderers being re-used.
          I don't think you will notice any speed diff between array or xml collections.
          You can set the number of rows and offscreen rows for your List. Setting offscreen rows to a higher number will create more renderers up-front. This makes scrolling a little smoother, but at the cost of longer load time for the component. Experiment with these two settings and find a good balance between load speed/scroll performance.
          • 2. Re: ArrayCollection vs. XMLListCollection
            Jed Schneider Level 1
            I'll check that setting out. Longer load time, in this case, is not much of an issue as it is for an enterprise solution and the clients are willing to wait a bit. Performance once loaded is a greater consideration. Thanks for the quick reply!
            • 3. Re: ArrayCollection vs. XMLListCollection
              rtalton Level 4
              Cool. I think you'll find the itemRenderers to be more of a performance hog than anything else, so plan on doing some tweaking to those for best performance.
              • 4. Re: ArrayCollection vs. XMLListCollection
                Level 7

                "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
                news:gkieln$g10$1@forums.macromedia.com...
                > I'll check that setting out. Longer load time, in this case, is not much
                > of an
                > issue as it is for an enterprise solution and the clients are willing to
                > wait a
                > bit. Performance once loaded is a greater consideration. Thanks for the
                > quick
                > reply!

                You may want to also try to optimize the renderer.

                If it's based on one of the Box components, try going to Canvas. If it's
                based on Canvas already, try UIComponent. If it's UIComponent already, try
                changing from Image to Loader. If you're using data binding in the
                renderer, try going to just setting the properties on the subcomponents in
                the next commitProperties() after a change in data.

                Of course, each one of these steps requires more expertise on your part, but
                if optimal performance is the goal, you'll find that's the best route.

                HTH;

                Amy


                • 5. Re: ArrayCollection vs. XMLListCollection
                  *gsb* Level 1
                  Perhaps your best bet is to make your own Sprite containing your image files appropriately arranged. Then scroll the Sprite.

                  If you make a custom preloader, you can load 'n' files before killing the preloader and starting the movie, while loading and adding the remaining images in the background.

                  This would surely give you a smooth scroller.


                  • 6. Re: ArrayCollection vs. XMLListCollection
                    Jed Schneider Level 1
                    Amy, I am with you, using something lighter weight than an image component to accomplish the display object.

                    Greg, i like this idea. One issue I've run into before with "pre-loading" images, is that the application doesn't like to wait for the loader to finish loading the images and adding them to a local array. I have attempted to use a listener to call the load next function but never to any level of success. Is there a code sample or project you know of that accomplishes this (eg, iteratively loading to an array before displaying them). If so, please point me in the right direction. Thanks,
                    jed