简体   繁体   English

AS3预加载外部SWF文件不会达到100%

[英]AS3 preloading external swf won't reach 100%

I have a flash interface file and I'm trying to load external swfs with a preloader. 我有一个Flash接口文件,我正在尝试使用预加载器加载外部swfs。 My problem is that the preloader never reaches 100% before trying to play the swf. 我的问题是,在尝试播放swf之前,预加载器永远不会达到100%。 The preloader will display, count up to a percentage and disappear. 预加载器将显示,计数到一个百分比并消失。 Then the swf just hangs for a few seconds on the first frame(some times over 10 seconds!) while it finishes loading. 然后,swf在完成加载时仅在第一帧上悬挂几秒钟(有时超过10秒!)。 It does eventually start playing. 最终它确实开始播放。 The percentage the loader reaches is completely random. 装载机达到的百分比完全是随机的。 It might reach 40% one time and only 7% the next. 一次可能达到40%,下次可能只有7%。

I'm loading the external swfs into an empty movieClip on stage called "visloader". 我正在将外部swfs加载到名为“ visloader”的舞台上的空movieClip中。

Here is my loader code: 这是我的加载程序代码:

loader= new SWFLoader("nameOfSlide.swf", {container:visloader, autoPlay:false, onProgress:progressHandler, onComplete:completeHandler});

loader.load();

And here are my progress and complete functions: 这是我的进度和完整的功能:

//--------------PROGRESS HANDLER----------------------------------------------------------------
function progressHandler(e:Event):void{
    //set alpha of loading animation to 1 so it is visible
    progClip.alpha = 1;
    progClip.loadPct.text = "" + Math.floor((loader.bytesLoaded/loader.bytesTotal)*100) + "%";
}

//--------------COMPLETE HANDLER-----------------------------------------------------------------

function completeHandler(e:Event):void{
    //hide the preloader animation
    progClip.alpha = 0;
    //myClip was created in the variables section above to hold the loaded swf
    //must use 'rawContent' to get control over the swf (play/pause, etc...)
    myClip = e.target.rawContent;       

    myClip.play();
}

"progClip" is a movieClip on stage with a spinning circle and a text field called "loadPct". “ progClip”是舞台上的movieClip,带有一个旋转的圆圈和一个名为“ loadPct”的文本字段。

The external swfs being loaded are pretty large. 正在加载的外部瑞士法郎相当大。 Some over 5 MB. 超过5 MB。 Not sure if that matters. 不确定是否重要。 I've used the exact same preloader for a different client with slightly smaller files and had no issues. 我为文件略小的文件的不同客户端使用了完全相同的预加载器,没有任何问题。 I'm at a complete loss. 我完全不知所措。

I don't think this has been asked before. 我不认为这是以前问过的。 I searched the forums and came up with nothing. 我搜索了论坛,却一无所获。 Hopefully someone here will know what I'm talking about. 希望这里的人会知道我在说什么。

Thanks in advance! 提前致谢!

If SWFLoader is firing the complete event too early, and you're can't see why by looking at the class itself, you could try checking - either in the progressHandler, with EnterFrame or a Timer - for when loader.bytesTotal == loader.bytesLoaded. 如果SWFLoader太早触发了complete事件,并且您无法查看类本身的原因,则可以尝试-在progressHandler中,使用EnterFrame或Timer-检查何时loader.bytesTotal == loader .bytes已加载。 When it does, remove relevant listeners and go from there. 完成后,删除相关的侦听器并从那里去。

Bit of a hack I know but if SWFLoader isn't working properly it's that, repair the class or get another library. 我知道一点技巧,但是如果SWFLoader无法正常工作,那就修复类或获取另一个库。 I'm gonna have a look at it myself now, for the meantime hope this helps/works! 我现在要自己看看,与此同时希望这对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM