Actionscript 3 在发布版本中加载flash.display.Loader块
我正在使用flash.display.Loader类从as3中编写的程序加载swf文件。在FlashDevelop中使用调试构建配置时,一切正常。但是,当我使用版本构建配置时,程序会在加载程序发送进度事件之后和发送完整事件之前冻结大约两秒钟 这是我的节目:Actionscript 3 在发布版本中加载flash.display.Loader块,actionscript-3,flash,loader,flashdevelop,Actionscript 3,Flash,Loader,Flashdevelop,我正在使用flash.display.Loader类从as3中编写的程序加载swf文件。在FlashDevelop中使用调试构建配置时,一切正常。但是,当我使用版本构建配置时,程序会在加载程序发送进度事件之后和发送完整事件之前冻结大约两秒钟 这是我的节目: package { import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.events.Pr
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;
import flash.text.TextField;
public class Main extends Sprite {
private var frameCounter:int;
private var frameCounterField:TextField = new TextField;
private var statusField:TextField = new TextField;
function Main():void {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.ENTER_FRAME, frame);
frameCounterField.text = "On frame " + frameCounter.toString();
addChild(frameCounterField);
statusField.y = 40;
statusField.width = 300;
addChild(statusField);
var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
var urlReq:URLRequest = new URLRequest("SomeFile.swf");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(urlReq, context);
}
private function frame(event:Event):void {
frameCounterField.text = "On frame " + (++frameCounter).toString();
}
private function onProgress(event:ProgressEvent):void {
statusField.appendText("Progress on frame: " + frameCounter.toString() +
" Loaded: " + event.bytesLoaded + " / " + event.bytesTotal + "\n");
}
private function onComplete(event:Event):void {
statusField.appendText("Completed on frame: " + frameCounter.toString() + "\n");
}
}
}
在release中,我在第一帧上获得以下输出:
第1帧上的
第1帧加载进度:0/182468
第1帧加载进度:65536/182468
第1帧加载进度:131072/182468
帧上的进度:1加载:182468/182468
程序冻结大约两秒钟后,添加第2帧上完成的行,并且“第X帧上”计数器开始滴答作响。调试生成生成相同的输出,但没有冻结
并非我尝试加载的所有swf文件都会触发该问题。文件的大小似乎没有任何影响。我曾尝试在另一台计算机上编译和运行,结果相同
什么会导致这个问题
编辑:我注意到,如果程序是用debug=true编译的,flash player启动大约需要两秒钟,与debug=false时flash player被冻结的时间相同。这不是您问题的直接答案,但是在Flash Player环境中加载程序的Event.COMPLETE事件的触发方面存在一些记录错误,即,和某些值
您可能正在运行这两个版本中的一个,因为您的调试器和发布版本可能在不同的启动时间或wmode设置下运行