GamePackage Loader Research

xiaoxiao2021-04-07  395

It's boring to study it.

A Loader and LoadQueue in GamePackage ... find that the author is indeed too big, I have already had 5 physicals of him PF ....

See Class Loader first, the author does not implement the MovieCliploader comes with Flash, but written a algorithm, it is estimated to be compatible with his own framework.

Look at the code, don't depends the details, like Implements Executeable, there is also Impulse.connect (this) ... etc. These are the implementation of the entire Package framework.

In the first constructor, some necessary parameters are defined. And hidden AsbroadCaster is used to broadcast some events. Here is the key, wait until LoadQueue can see the author's clever use.

The LOAD method is the beginning of a download.

Then, the private loadClip method is the author's own Loading algorithm to simulate MovieCliploader (MCL). To study, you can see the author's strong attainments for Flash.

The judgment of Mode == 1 is to determine if the downloaded file has been connected. If it is connected, the container ._URL and the URL of the download file are definitely the same, then this moment is just that the file is correctly connected. Broadcast OnLoaderRequest event. This event is onloadstart in the MCL. This skill is great ...

When it is properly connected to the file, it is estimated that Flash Player has the total size of the load file, before TOTALBYTES is equal to -1. So first judge whether it is equal to -1, when it is greater than -1, the document is really started to download. This Time to broadcast OnLoaderstart. In MCL, there is no accurate this incident, and maybe MM's people have never thought about it. Because it is an initial operation of the container when it is accurately connected to the file.

People who use LoadMovie should know that the container is in the LoadMovie, the MC in the main file is referred to. If this time is defined for the MC, there is no attribute value before LoadMovie.

The best way is to define some properties of the container when the external SWF is loaded.

At any time, the container starts equal to the external SWF? Remember before, I just judge the container .GetBytestotal, but getBytestotal This function is very inexplicable. For example, a MC's getBytestotal is equal to 0, and if you request a connection in LoadMovie request When it is equal to -1, after connecting, a few frames are 0, the anti-and network speed has a big relationship, and it is really impossible to accurately, and the author uses _url to judge, it is undoubtedly more accurate to getBytestotal. Clear.

The next thing is routine, and when Mode == 4, the author's judgment seems to lack practical significance, I test it. The author's onlineercomplete and the onloaderinit event triggered are similar. OnloadComplete and OnLoadInit in the MCL are very Distinguished distinction, OnloadComplete in the MCL has not been executed before the external SWF file is loaded.

Executing the AS step is

Mcl.onLoadComplete

External SWF first frame AS

Mcl.onLoadInit

It can be said that MCL is more accurate in the download of the end time.

After all, the author is written on the basics of Flash. No MCL is so powerful (Flash8, MCL can give httpstatus when OnLoaderror), this is already enough unless otherwise needed.

转载请注明原文地址:https://www.9cbs.com/read-132509.html

New Post(0)