我有一个图像,我正试图加载,然后重新加载。这是我对图像的加载代码:as3:重新加载图像
public function loadImage(url:String, _w:int, _h:int):void
{
this._stwidth = _w;
this._stheight = _h;
this._imageURL = url;
if(!_imageURL)
{
return;
}
this.alpha = 1.0; //need this because we might have just faded the image out
_ldr.alpha = 0.0;
_prog.alpha = 1.0;
_sqr.alpha = 0.0;
_sqr.graphics.clear();
if(_hasLoaded)
{
try
{
_ldr.close();
_ldr.unload();
}
catch(e:Error)
{
//trace("bmdisplay has loaded once, but there was an error: " + e.message);
}
}
_ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
_ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
_ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
_ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
_ldr.contentLoaderInfo.addEventListener(Event.INIT, onOpen);
_ldr.load(new URLRequest(_imageURL));
}
出于某种原因,没有第2次负载发出错误的代码将不会加载图像。 有人可以帮我解决这个问题吗?
我完全失去了为什么我的变量_asLoaded会做我的错。 我有一个onComplete()处理程序,它将该var设置为true,之后我从未将其设置为false。
我不知道还有什么我应该尝试...
感谢
我已经想到了这一点,虽然我喜欢你的解决方案,使用removeChild()和addChild()来包装它。最终,我目前正在运行的(并且不会产生任何错误的)答案是简单地重新加载一个新的映像,_不再循环加载器,_not_ try/catch,并且在完成此类之上的其他类时为其分派事件在显示列表链中。 – jml 2010-01-18 10:46:55