The impact of the loading position on the movie when the movie is loaded in Flash

Source: Internet
Author: User
Tags file size
Loading| loading

In the forum often see loading load way of discussion, but most are discussed with what kind of loading method and code, today I want to load the movie in Flash, loading position on the impact of the film. Flash loading has a variety of production and loading methods, The focus of this paper is to discuss the impact of the location of the loading on the movie when the external SWF file is loaded in the main movie. That is, the loading is written inside the main movie or in the movie.

First, consider from the cache, because the browser can cache flash files, so loading is placed inside the main movie, or is not affected by the loaded movie, the first time the browser automatically caches these files. From operation and maintenance analysis, the loading on the main movie can be written as a function, You can then call this function when you load an external SWF file, which is easy to maintain, and you can also use loading if you are loading a JPG and so on. The loading with different films in the externally loaded external file are independent of each other, can produce a variety of loading effects. Analyze from response and load speed: [same main file and external loading file, Flash mx2004professional]
1: The main file internal loading load external files to test:
Create a New button in the main file and a progress bar called Jindutiao, as the following code:

On (Press) {

T1 = Gettimer ();

_root.createemptymovieclip ("M1_MC", 2);/Set up an empty MC

M1_mc.loadmovie ("1.swf");/loading an external file with a name of 1.swf

M1_mc._visible = false;

_root.onenterframe = function () {

T2 = Gettimer ();

var L = m1_mc.getbytesloaded ();//Get the number of bytes downloaded

var t = m1_mc.getbytestotal ();//Get total number of SwF bytes

per = Int ((l/t) *100);//per is a dynamic text box

if ((l>=t) && (t>0)) {

T3 = Gettimer ();

Trace (T3);

Trace (T3-T2);

Trace (T2-T1);

Delete this.onenterframe;//Remove Frame trigger Event

m1_mc._visible = true;//Make MC visible

Jindutiao._visible = false;//to make progress bar invisible

m1_mc._x = 0;//Adjust position, also can adjust other properties

m1_mc._y = 0;

} else {

Jindutiao._visible = true;

SetProperty ("Jindutiao", _xscale, per);

}

}

}

Parameters:
When the loading code is written inside the main file, the primary file size is 3792 bytes, the file 702539 bytes loaded, 5 tests are performed under 33400b/s bandwidth, and the time is distributed as follows:

21034ms

21048ms

21021ms

21060ms

21082ms

Average: 21049ms, two films total bytes: 706331
2: Test the main file for external files containing loading:
Create a New button in the main movie and a progress bar called Jindutiao movie



_root.m1_mc._x = 0;

_root.m1_mc._y = 0;

}

}



Write loading as code in the external file being loaded:



First frame:

Total = Getbytestotal ()//note, do not use _root.getbytestotal (), because the path problem is caused by avoiding being loaded into the main movie

loaded = getbytesloaded ();

Baifenshu = Int ((loaded/total) *100);

Baifenbi = baifenshu+ "%";

SetProperty ("Jindutiao", _xscale, Baifenshu);

t = Gettimer ();

Second frame:

if (Baifenshu = = 100) {

Trace (t);

gotoAndPlay (3);

} else {

gotoAndPlay (1);

}

Parameters:
When the loading code is written in an external file that is loaded, the primary file size is 3395 bytes, the file is 702971 bytes loaded, 5 tests are performed under 33400b/s bandwidth, and the time is distributed as follows:


21038ms

21094ms

21033ms

21038ms

21030ms

Average: 21046.6ms, two films total bytes: 706336
The difference between loading in two ways is not obvious, so you can choose the appropriate loading method depending on your needs.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.