我正在尝试预加载具有嵌入 swf 源的 swf。但它不想工作。我尝试了简单的预加载,但进度事件仅在加载后运行。任何想法?
public class MainShell extends MovieClip
{
[Embed(source = "Main.swf")]
public var cs:Class;
public var hsf8z42fdfd_as32:MovieClip;
public function MainShell()
{
addEventListener(Event.ADDED_TO_STAGE, initialize, false, 0, true);
}
private function initialize(e:Event) {
loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error, false, 0, true);
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress, false, 0, true);
loaderInfo.addEventListener(Event.COMPLETE, loaded, false, 0, true);
}
private function progress(e:ProgressEvent) {
var done:Number = stage.loaderInfo.bytesLoaded;
var total:Number = stage.loaderInfo.bytesTotal;
var w:int = done / total * 100;
loading.TT.text = String(w);
}
private function loaded(e:Event) {
loading.parent.removeChild(loading);
hsf8z42fdfd_as32 = new cs();
hsf8z42fdfd_as32.addEventListener(Event.COMPLETE, onComplete);
}
private function error(e:IOErrorEvent):void{
trace("Error!");
}
public function onComplete(e:Event) {
addChild(hsf8z42fdfd_as32);
}
似乎进度功能仅在文件实际加载后运行一次。进度事件应该在加载时运行,那为什么不呢?