how to avoid flickering when changing the source of an mx:Image in flex
i开发者_运维百科n my mxml file I have images declared like this:
<mx:Image x="0" y="0" source="assets/bigpicture.png" id="picture1"/>
and at some event I do:
picture1.source = "assets/bigpicture2.png";
However this results in flex removing the picture, and when it has loaded it will show it again.
How can I make the mx:image make so that it will continue to show the image until the new image has been loaded?
thanks!
Why don't you just embed your assets in your application if they are always the same ?
If your images must be loaded at runtime: I think the only way to do it is to load the asset separately from the Image with a Loader, and when the Loader has finished loading, assign it as source of the Image.
Else, you can just fade the Image to alpha=0 before switching the source, and then fade it back to 1.0. It will look smoother, but there will still be no image displayed while the new one is loading.
精彩评论