AS3加载屏幕

编程入门 行业动态 更新时间:2024-10-25 02:26:04
本文介绍了AS3加载屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何创建这些加载中,请稍候闪屏的加载条和百分比为你的SWF?请问AS3有一些内置的方法,还是应该从头开始设计的?

How do you create these "loading, please wait" splash screens with a loading bar and percentage for your swf? Does as3 have some built-in methods or should it be designed from scratch?

我的意思是,你怎么发现你的SWF文件被加载到客户端的浏览器?

I mean, how do you detect that your swf file is being loaded into client's browser?

呵呵,我有我的所有内容存储在只有一帧。纯AS3 code。

Oh and I have all my content stored in one frame only. pure as3 code.

推荐答案

如果您所有的code是在时间轴上,那么最简单的方法是使仅用于加载主SWF第二瑞士法郎。如果你的主SWF被称为的main.swf 中,code在加载SWF将是这样的:

If all of your code is on the timeline, then the easiest way is to make a second swf that is only used for loading your main swf. If your main swf is called main.swf, the code in your loading swf would be something like this:

//make a loader var loader:Loader = new Loader() //listen for loading progress loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress); //listen for when the load is finished loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); //load! loader.load(new URLRequest("main.swf")); function onProgress(event:ProgressEvent):void { //calculate how much has been loaded var percentageLoader:Number = event.bytesLoaded / e.bytesTotal; //use your percentage number here to drive a loader bar graphic } function onComplete(event:Event):void { //remove listeners now that loading is done loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress); loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete); //add loaded swf to the stage addChild(loader.content); }

顺便说一句,外化你的资产开辟了新的preloading可能性。而不必一切都在你的主SWF,你可以有你的主SWF加载外部资产,preLOAD这些资产。由于您的主SWF会那么小,就没有必要有第二个SWF只为您加载主SWF。

As an aside, externalizing your assets opens up new preloading possibilities. Instead of having everything in your main swf, you can have your main swf load external assets, and preload those assets. Since your main swf would then be small, there would be no need to have a second swf just for loading your main swf.

更多推荐

AS3加载屏幕

本文发布于:2023-11-23 15:44:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622001.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   屏幕

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!