AS3 预加载器是内部还是外部?
我想知道加载 Flash 游戏的最佳方式是什么。我知道如何制作外部预加载器,但如果我想将游戏的 .swf 上传到 newgrounds 这样的网站,我猜我需要一个内部预加载器。
我已经尝试了几次,但我的游戏仅在 swf 100% 加载后才显示。当它加载时,我只看到带有灰色“...”的白色屏幕,我猜它是内置于 Flash 播放器中的。
我有一个名为 AsteroidsGame.fla 的 .fla 文件,其中包含一些类的库,并且游戏的结构被编码到名为 AsteroidsGame.as 的 .as 文件中。也许这会引起问题?我不知道,但我真的很感激任何关于启动和运行预加载器的帮助。
谢谢。
I was wondering what the best way to load my flash game would be. I know how to make an external preloader, but if I want to upload the .swf of the game to a site like newgrounds, Im guessing I need an internal preloader.
I've tried a few times but my game only displays after the swf is 100% loaded. While its loading I just see white screen with grey "..." which im guessing is built into the flash player.
I have a .fla called AsteroidsGame.fla which has a library of some classes, and the game's structure is coded into a .as file called AsteroidsGame.as. Maybe this is causing issues? I dont know, but I'd really appreciate any help getting a preloader up and running.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简而言之,加载时,Flash 播放器将从第 1 帧开始,并继续停留在那里,直到加载第 1 帧上的所有数据。只有这样它才会进入下一帧。您可以通过选中“File->Publisher Settings”下“Flash”选项卡中的“Generate Build Report”复选框来获取导出到每个帧的数据字节数的详细报告。
要获得简单的加载显示,请添加在第 1 帧中创建一个名为“loader_txt”的 TextField,并在操作中添加此代码:
要确保您的资源和 ActionScript 代码导出到第 1 帧之外,以便上述代码可以在 Flash 影片开始加载时立即启动,请转到“文件 -> “发布设置”,选择“Flash”选项卡,然后单击“脚本”右侧的“设置...”按钮。应该会出现一个对话框。在该对话框中的“导出框架中的类:”下,输入 2。
对于库中的资源,您可能需要执行类似的操作。右键单击库资源并选择属性,您将看到取消选中“在第 1 帧中导出”的选项。如果取消选中它(这意味着 Flash 影片可以在加载此资源之前开始播放),则必须确保在时间线中第 1 帧之外的某个位置有对该符号的引用,否则 Flash 将从编译中忽略它。
祝你好运!
In short, when loading, the flash player will start on frame 1, and will continue to sit there until all the data on frame 1 has been loaded. Only then will it proceed to the next frame. You can get a detailed report of how many bytes of data is exported to each frame by checking the "Generate Build Report" checkbox in the "Flash" tab under "File->Publisher Settings"
To get a simple loading display going, add a TextField named "loader_txt" in frame 1, and add this code in action:
To make sure your assets and actionscript code are exported beyond frame 1 so above code can kick in immediately when flash movie begins to load, go to "File->Publish Settings", select "Flash" tab, and click on "Settings..." button to the right of "Script". A dialog should show up. In that dialog, under "Export classes in frame:", enter 2.
For assets in library, you may need to do similar thing. Right click on a library asset and select properties, and you'll see the option to uncheck "Export in frame 1". If you uncheck it (which means flash movie can start to play before this asset is loaded), you will have to make sure you have a reference to that symbol somewhere beyond frame 1 in the timeline, otherwise Flash will omit it from the compilation.
Good luck!
外部的。有了适当的安全权限,您应该能够在大多数环境中将内容从远程位置加载到 shell 中。
使用内部加载器加载时看到的延迟可能是由您在运行时为动作脚本导出的库资源引起的。它们将被导出到第一帧。在该帧加载之前,您看不到任何预加载,一旦完成导出这些资源,预加载器逻辑将跳转到第一帧的加载百分比。
External. With the proper security permissions you should be able to load content from a remote location into a shell in most any environment.
The delay you see when loading with an internal loader is likely caused by library assets your are exporting for actionscript at runtime. They will get exported to the first frame. until that frame loads you can't see any preloading and your preloader logic will jump to the percent loaded of that first frame once it has finished exporting those assets.