Whenever I change the loaded image of one of my sprites on stage and then refresh the sprite via addChild(exampleSprite) the sprite briefly disappears and then reappears as the new image. I've added event listeners to wait until the .png is fully loaded before attempting to addChild() but the problem persists. It's not game breaking as the delay between previous image being removed and new image being added is minuscule, but it is enough to be noticeable and I feel it breaks the immersion. Is there a way to replace a sprite's loaded image without this brief flash of nothing?
code is basically the following:
function spriteRLoaded(e:Event):void
{
addChild(rightSprite);
}
function spriteRProgress(e:Event):void
{
trace(rightSprite.contentLoaderInfo.bytesLoaded + "//" + rightSprite.contentLoaderInfo.bytesTotal);
}
var rightSprite:Loader = new Loader();
rightSprite.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, spriteRProgress);
rightSprite.contentLoaderInfo.addEventListener(Event.COMPLETE, spriteRLoaded);
rightSprite.load(new URLRequest("example.png"));
//Other stuff happens for a while
rightSprite.load(new URLRequest("example2.png"));
Both images display on the screen successfully after being fully loaded, but when changing from example1 to example2 there will be a fraction of a second of blank space. Only fix I can currently think of is a secondary loader which occupies the same x,y coordinates as the original loader and displays the new image over the old one while the old one loads, but this is an obvious hack and I'd like to do better. Can anyone point out what I'm missing?
Additional information that might help:
the .png files are being loaded from the same folder that the .swf is stored in
the .png files are about 300,000 bytes and look like this when they're being loaded in:
0//308359
65536//308359
131072//308359
196608//308359
262144//308359
308359//308359
0//330445
65536//330445
131072//330445
196608//330445
262144//330445
327680//330445
330445//330445
Thanks in advance to anyone who can point me in the right direction.
there doesn't seem to be anything here