How to Manage Flex 3-Cache Image Management

According to adobe flex docs: http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html

Using the image multiple times

You can use the same image multiple times in your application using the standard image import syntax each time. Flex downloads the image only once, and then downloads the downloaded image as many times as needed.

However, when testing, we found that if you request the same image (the same url, etc.) in IE flash 9/10, a new HTTP request will not be issued, but with Firefox, Safari (PC and MAC) A new request is always issued.

I want the image not to be pulled from the server every time I try to use it, who has an idea why this only works in IE?

+3
source share
6 answers

Here is the answer: NEVER think that IE is doing it right. IE was wrong, all other browsers were correct. .Swf files were returned using Cache-control: private header. IE should not return a cached image. Correctly configuring the Cache-Control header has caused all browsers to behave as expected.

+4
source

One way to solve the problem is to create your own image cache using ActionScript by saving the BitMapData of the original instance and using it as a source for subsequent instances:

private var image1:Image = new Image();    
private var image2:Image = new Image();                 

private function init() : void
{
    image1.addEventListener(Event.COMPLETE, onComplete);
    image1.source = "icon.png";
    addChild(image1);   
}


private function onComplete(event:Event) : void
{   
    var image:Image = event.target as Image;                
    var bitmapData:BitmapData = new BitmapData(image.content.width,
                                               image.content.height, true);    
    bitmapData.draw(image.content);         
    image2.source = new Bitmap(bitmapData);
    addChild(image2);
}

.

+4

, flex - , .

:

[Embed(source="myImage.jpg")]
[Bindable]
public var myImageClass:Class;

+2

, source:

<mx:Image id="myImage" source='blah.png'/>

var myNewImage:Image = new Image();

myNewImage.source = myImage.source;
+1

, , IE , FF, Safari, Chrome .. ? (IE7 btw).

. mx: Image mx: SWFloader. , URL- , . mx: Image, , reset, .

0

- . , .

-1

All Articles