【发布时间】:2014-02-13 19:16:15
【问题描述】:
我有一个外部 SWF,我计划使用它来加载包含需要能够在不更改源文件的情况下进行更改的内容的影片剪辑。
我让它加载得很好,一切都运行良好,然后我卸载它,将值设置为 null 只是为了安全起见,应用程序仍然可以正常运行而没有错误,但是当我再次尝试加载它时,我的跟踪显示它正在加载 100%,但最终的 onComplete 函数似乎没有触发,除非我再次单击加载按钮,但随后它加载了 swf 的另一个副本。
有人遇到过类似的事情或知道发生了什么吗?
编辑:这是代码示例:
var swfFileName:String = "path/to/file.swf";
var swfFilePath:File = File.applicationStorageDirectory.resolvePath(swfFileName);
var inFileStream:FileStream = new FileStream();
inFileStream.open(swfFilePath, FileMode.READ);
var swfBytes:ByteArray = new ByteArray();
inFileStream.readBytes(swfBytes);
inFileStream.close();
var loader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loaderContext.allowCodeImport = true;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, loadError);
loader.loadBytes(swfBytes, loaderContext);
这是删除代码:
function remover(event:Event = null):void {
loader.unloadAndStop();
loader = null;
swfFileName = null;
swfBytes = null;
loaderContext = null;
trace("removed");
}
在 swfLoaded 函数中添加了一些内容并删除了 remover 函数,但我已经删除了这些内容以尝试缩小此示例中的原因。从我已经完成的跟踪中,Progress 事件中的百分比跟踪是在函数的第二次加载期间没有其他任何事情发生之前在 100 处触发的最后一件事。我第一次尝试运行它时,它运行良好,并以完美的功能显示所有内容。
【问题讨论】:
-
分享您的代码。我们的心灵感应能力仍然很弱。 ;)
-
你好吗
unloadingSWF?
标签: actionscript-3 flash loader