Flex: Caching images in list item renderer?
Asked Answered
H

3

7

I have a List and the item renderer displays an image. Whenever you scroll the list, and the item renderer refreshes, it redownloads the image. Causing there to always be a delay. Is there some way of caching it so it doesn't have to redownload every time causing a delay in showing the image every time you scroll the list?

Thanks!

Hess answered 20/10, 2009 at 20:28 Comment(0)
R
3

Here is nice solution with source code http://demo.quietlyscheming.com/superImage/app.html

Remand answered 20/10, 2009 at 22:15 Comment(1)
It is pretty ridicules that so much custom code is needed for such a simple and common thing!Eurhythmic
M
0

You'll have to implement your own caching. I would store all the images that have been previously downloaded and load them if the user goes back to them.

Minium answered 20/10, 2009 at 21:24 Comment(0)
Y
0

I remember doing this a while back for some project But the way I did approach this was

When the call is first made to get the image, check if in the cache directory (a directory of your choice) the image exists (read ahead to find out how to relate the images), if it exits then load it, else download the image and save the image name as perhaps a hash of the data that the image represents, or something that can represent a valid key for the data without getting a collision.

For example,

Thumbnail 1 - String 1 Thumbnail 2 - String 2

I save thumbnail 1 as a hash of string 1, then the next time i encounter this string 1, i check in the cache directory if the image exists that represents this, and i simply load it, else i download it, save it and etc like i said before :)

Yousuf answered 20/10, 2009 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.