1 Reply Latest reply on Nov 17, 2011 9:06 AM by kevinklin

    Redraw issue with Spark List

    rjoshicool Level 2

      I have a list component which displays a VBox as an Item Renderer. This VBox has an image and a text. The image is coming from server. What happens is that when I scroll the list, the images for new items in view are loaded. But when I go back to the items at top, they are no more there and request is sent again to server to get the image. Is there some way I can prevent this redrawing of images?

        • 1. Re: Redraw issue with Spark List
          kevinklin Adobe Employee

          Spark List uses virtual layout meaning only the item renderers in view are created and displayed. This also means that item renderers are reused. You probably want to cache the images in a ContentCache. You can create a static cache for all your renderers to use. For example:

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

                          xmlns:s="library://ns.adobe.com/flex/spark"

                          xmlns:mx="library://ns.adobe.com/flex/mx"

                          autoDrawBackground="true">

             

              <fx:Script>

                  <![CDATA[

                      import spark.core.ContentCache;

                     

                      private static var contentCache:ContentCache = new ContentCache();

                     

                  ]]>

              </fx:Script>

             

              <s:layout>

                  <s:VerticalLayout/>

              </s:layout>

             

              <s:Label text="{data}"/>

              <s:Image source="{data.url}" width="100%" contentLoader="{contentCache}" />

             

          </s:ItemRenderer>