[英]Preloader to load external SWF without PROGRESS and COMPLETE events
I have created the following preloader saved as "preloader.swf" that loads an external SWF file as follows:我创建了以下预加载器,保存为“preloader.swf”,它加载外部 SWF 文件,如下所示:
var req:URLRequest = new URLRequest("main.swf");
var loader:Loader = new Loader();
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.OPEN, showPreloader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showContent);
var preloader:Preloader = new Preloader();
function showPreloader(event:Event):void
{
addChild(preloader);
preloader.x = (stage.stageWidth / 2) - (preloader.width / 2);
preloader.y = (stage.stageHeight / 2) - (preloader.height / 2);
}
function showProgress(event:ProgressEvent):void
{
var percent:Number = event.bytesLoaded / event.bytesTotal;
preloader.percentage.text = Math.round(percent * 100) + "%";
preloader.bar.width = 300 * percent;
}
function showContent(event:Event):void
{
removeChild(preloader);
addChild(loader);
}
I was reading to try avoid the PROGRESS and COMPLETE events since these events don't work 100% of the time.我正在阅读以尝试避免 PROGRESS 和 COMPLETE 事件,因为这些事件在 100% 的时间内都不起作用。
Now my question is this: is there a way of how I can go about to have the same functionality of loading an external SWF file (as above) but WITHOUT using the PROGRESS and COMPLETE events?现在我的问题是:有没有办法让 go 具有加载外部 SWF 文件的相同功能(如上所述)但不使用 PROGRESS 和 COMPLETE 事件?
If so, can anyone suggest me what coding to add/change?如果是这样,谁能建议我添加/更改什么编码?
Thanks.谢谢。
HAve you tried with a Timer?你试过定时器吗? You check at every interval is the SWF is loaded entirely or not.
您每隔一段时间检查一下是否完全加载了 SWF。
However, PROGRESS and COMPLETE events should always work.但是,PROGRESS 和 COMPLETE 事件应该始终有效。 What's not working in your project?
你的项目有什么问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.