tags:

views:

352

answers:

1

Hello

I load the same image in Flex from different places - and the image always load from server again and again.

Is there any way to load image from browser cache?

Thanks

Vladimir

A: 

If you know that you are going to be loading the image in 4 different places have you considered embedding the image inside the swf, then you wouldn't need to load it at all.

If that isn't an option then you could create a Dictionary of images, using the source of the image as the key. If a particular key hasn't been populated then you haven't loaded that image yet, and if it is populated then you can reference the image from the Dictionary (that way you only load it once).

Place the Dictionary inside a singlton class so that it can be made accessable from anywhere in your app.

Kenneth.

kenneth
However, a single image can only have one parent in the displaylist, so to do that you will need to clone it using BitmapData
grapefrukt
Actually, he can just make new Image() object and copy source, height and width of original image. No need to clone whole object.
Vugluskr
indeed (be away for a bit so missed comments) cloning is over the top, just grab the source from the dictionary class and place into new image.
kenneth