【发布时间】:2014-08-23 18:44:49
【问题描述】:
我在已编译的 SWF 上调用 loadStyleDeclarations,但它从未完成,例如,当我添加事件侦听器时,会调用 PROGRESS 事件,但会调用 COMPLETE 和 ERROR 事件从来没有打电话。我添加了一个百分比检查器来查看发生了什么,它达到了 100% 并且......只是没有调用 COMPLETE 事件。
var dispatcher:* = StyleManager.getStyleManager(null).loadStyleDeclarations(asset, true, true, ApplicationDomain.currentDomain);
dispatcher.addEventListener(StyleEvent.PROGRESS, onProgress);
dispatcher.addEventListener(StyleEvent.COMPLETE, onComplete);
dispatcher.addEventListener(StyleEvent.ERROR, onError);
..
private function onProgress(e:StyleEvent):void
{
//update progress bar here
trace(Math.floor(100 * e.bytesLoaded/e.bytesTotal) + "% loaded");
}
private function onComplete(e:StyleEvent):void
{
trace("Style loaded");
}
private function onError(e:StyleEvent):void
{
trace("Error loading style");
}
输出:(style.swf 是我要加载的)
[SWF] C:\Projects\music\bin-debug\Main.swf - 5,656,958 bytes after decompression
0% loaded
83% loaded
100% loaded
[SWF] C:\Projects\music\bin-debug\style.swf - 167,143 bytes after decompression
100% loaded
[SWF] C:\Projects\music\bin-debug\style.swf\[[DYNAMIC]]\1 - 1,223,478 bytes after decompression
[SWF] C:\Projects\music\bin-debug\style.swf\[[DYNAMIC]]\2 - 763,122 bytes after decompression
[SWF] C:\Projects\music\bin-debug\style.swf\[[DYNAMIC]]\3 - 2,083,945 bytes after decompression
关于为什么COMPLETE 事件永远不会触发的任何想法?
【问题讨论】:
标签: actionscript-3 flash apache-flex