我在我编译的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事件从来不触发,有什么想法吗?
发布于 2014-08-24 07:41:06
原因可能在您的CSS swf文件中。我刚刚用非常基本的css (用于Flex应用程序的样式)检查了您的代码。
s|Application {
backgroundColor: red;
} 你的代码就像预期的那样正常工作。难道是因为你的CSS更复杂吗?输出还显示了从style.swf加载其他一些动态内容。
SWF C:\Projects\music\bin-debug\style.swf[DYNAMIC]\1 -解压缩后的1,223,478字节
[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 decompressionhttps://stackoverflow.com/questions/25465248
复制相似问题