Archive for the ‘url image’ tag
Workaround for Cached URL Images in Flex
Just this past week I had found myself wrestling with a Flex application that can crop images on the fly, and display in two different places and two different sizes, a thumbnail of the new image.
One of the biggest headaches in the process was Flash’s caching of the previous URLs when another one has been added in its place. Clearly this causes an inconsistency in ‘what you see is what you get’ (WYSIWYG). So I had to find a solution.
The Image component in Flex has a cachePolicy property (inherited from UIComponent) that will ensure the component’s bitmap values are not cached, but straight URLs are not affected by this.
However, I found a workaround after a good deal of searching the net, and poking and prodding through the nooks and crannies of Flex.
Initially I was going to generate a bitmap of every image brought into the application, but the overhead would have been outrageous, and the simplicity of the program is the service call to generate the new cropped image and return the URL. But it turns out that by adding a random-numbered query string to the end of the incoming URL, the extra value will force the retrieval of the new image.
It worked like a charm, and the only drawback is that all images, changed or unchanged, are re-retrieved with every refresh of the display (in my case, when a component is set to visible, it makes a service call to populate data).
In my case, the value for the URL is kept in in a value object and in the get accessor for its value, I did the following:
1 2 3 4 | public function get urlValue():String { return _urlValue + "?" + Math.random(); } |