对于SWF preloader与嵌入字节组 [英] Preloader for SWF with embed bytearray

查看:112
本文介绍了对于SWF preloader与嵌入字节组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已编译的SWF没有显示在preloader直到整个SWF完全加载。任何HEPL将是真正的AP preciated,我用Google搜索了整整一夜不可能找到这样的东西,至少对我来说。

The complied SWF is not showing the preloader until the whole SWF completely loaded. Any hepl would be really appreciated, I googled the whole night couldnt find anything on this, at least for me.

推荐答案

您不能嵌入的ByteArray 到主文档类,因为这是从文件引用的类类将自动包含在框架1。

You can not embed the ByteArray into your main document class, because classes that are referenced from the document class will automatically be included on frame 1.

要preLOAD资产的最好方法是有一个单独的preloader类和主类。您希望您的preloader类在第1帧,和主类和资源导出的框架2。

The best way to preload assets is to have a separate Preloader class and Main class. You want your Preloader class to export on frame 1, and your Main class and assets on frame 2.

不幸的是,这是棘手比它应该的,但在这里是你如何能做到这一点:将你的文档类 preloader 。这个类包含了你的的LoaderInfo code。然而,当你完成加载,不实例主要直接,即不做 VAR主:主=新的Main()。这将自动导致主要被编译到帧1,无论你做什么。相反,实例化它间接地,像这样的:

Unfortunately, this is trickier than it should be, but here's how you can do it: Set your document class to Preloader. This class contains your loaderInfo code. However, when you finish loading, do not instantiate Main directly, i.e. do not do var main:Main = new Main(). This will automatically cause Main to be compiled onto frame 1 regardless of what you do. Instead, instantiate it indirectly, like this:

nextFrame(); // you sometimes need to do this for the player to register classes exported on frame 2
var mainClass:Class = flash.utils.getDefinitionByName("Main") as Class;
var main:Sprite = new mainClass();
addChild(main);

这将停止编译器自动唬弄主要到第1帧。

This will stop the compiler from automatically yanking Main onto frame 1.

接下来,如果您使用Flash CS3 + IDE中,进入文件 - >发布设置 - > FLASH->的ActionScript 3.0的设置和更改帧2的框架导出类设置为随后帧2,您的电影,把一个空的影片剪辑。在这个影片剪辑,将引用主类通过把这个code: VAR哑:主; 。你必须做的原因是为了让编译器仍然会知道你使用的是主,所以它实际上将其编译成电影,否则将不对其进行编译的。你也不想把这个主时间轴上,因为主时间轴上的任何code引用被自动地猛拉到第1帧。

Next, if you are using the Flash CS3+ IDE, go to File->Publish Settings->Flash->ActionScript 3.0 settings and change the "Export classes on frame" setting to frame 2. Then, on frame 2 of your movie, place an empty MovieClip. Inside this MovieClip, place a reference to your Main class by putting this code: var dummy:Main;. The reason you have to do this is so that the compiler will still know you are using Main, so it will actually compile it into the movie, otherwise it would not compile it at all. You also don't want to put this on the main timeline, because any code references on the main timeline automatically get yanked onto frame 1.

在IDE中,一个有用的技巧来检查,事情已经出口在适当的地方是检查生成大小报告的发布属性 - >闪光。您可以检查报告,将很容易发现,如果垃圾已出口到第1帧。

In the IDE, a helpful trick to check that things have exported in their proper place is to check "Generate size report" in Publish Properties->Flash. You can examine the report and will easily notice if junk has exported onto frame 1.

如果您正在使用Flash Builder,FlashDevelop中,或FDT,这个过程基本上是一样的 - 创建单独的preloader及主要课程,并从preloader实例主要是间接的。但是,信号编译器后preloader框架编译主,把这个元标记以上公共类主要 Main.as

If you are using Flash Builder, FlashDevelop, or FDT, the process is basically the same--create separate Preloader and Main classes, and instantiate Main indirectly from Preloader. But to signal the compiler to compile Main on a frame after Preloader, put this metatag above public class Main in Main.as:

[Frame(factoryClass="Preloader")]

FlashDevelop中还可以通过点击+旁边的项目选项卡反省的SWF文件。它会告诉你什么资产,已出口到该帧。理想情况下,你只需要在第1帧的最低限度的preloader。

FlashDevelop can also introspect SWF files by click on the + beside it in the Project tab. It will show you what assets have been exported onto which frames. Ideally, you only want the bare minimum of Preloader on frame 1.

这篇关于对于SWF preloader与嵌入字节组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆