Flash Web page Production details of the production of loading

Source: Internet
Author: User
Tags extend integer
Loading| Web page
You know, when the Flash movie or Web page volume is quite large, waiting for the appearance of the page is very boring, so the concept of loading produced
There are many ways to make a loading, and today we'll talk about one.
Okay, turn to the point.
First, Ctrl+f8 creates a new movie clip (MC), named loading.

Then, enter this MC, do a box, without a border, leaving only fill color, select the Chinese box, press F8 to convert to graphic components. Then press F6 to do a keyframe in frame 100th. Back to the first frame, with the Freeform tool (Q), drag the loading bar from left or right like the middle, drag it to a line, and then make a tween from the first frame. This loading animation is an extension from the middle to both sides, as for why to do 100-frame gradient animation, that is, with 100% as slightly, to 100% download, this bar extends over!
Next, the name of the loading MC dragged into the scene of the first layer, put in the appropriate position, point F5 extension one frame. Name the MC instance as loading.

And then into our as part.
To create a new layer in the home scene, click F6 to extend a keyframe, because the first frame is a blank frame, so the second frame also extends a blank keyframe.

The first frame is written as:
A=getbytesloaded (); A is defined as getbytesloaded ()
B=getbytestotal (); b is defined as getbytestotal ()
Loaded=int (a/b*100); Defined as a divided by B and multiplied by 100, the purpose is to find a hundred-point integer, in fact, for this loading effect is not, but to make a foundation for later functional detailed loading useful.
Loading. gotoAndPlay (loaded); Loading here is the instance named in the scene of the loading, in the download at the same time, run this MC, with the above hundred integer display the entire download process.

The second frame is written as:
if (a==b) {//If a value of the download equals the total value of the flash itself, execute the following statement
Nextscene (); Go to the next scene, where you can see that the active and loading scenes here are different, so we'll use SHIFT+F2 to create a new scene, put in the active painting, and must be under the loading scene.
}else{//Other case, that is, a is not equal to B, most of the load is not completed in the case,
gotoAndPlay (1); Back to the first frame, do a loop, and when the loading is unsuccessful, return to the first frame to perform the download again.
}
This is done, remember, the active painting should be placed in another scene and under the loading scene.

This time we introduced using as with dynamic and static text to complete the display of the detailed download process, temporarily decided to add a percentage of the display.
Last introduced the progress bar, this time, not to mention the direct access to the percentages and download process.
First, the scene is written with static text in the appropriate 7 locations: Total bytes, downloaded bytes, total frames, downloaded frames, time required, actual time spent, and%, and then a frame is extended with F5 on the timeline.
Then, on the top six, pull out 6 boxes of the right size with dynamic text, without writing anything, and pull out a 3-digit box on the right side of "%" with dynamic text.
Then add variables to the dynamic text box corresponding to the static text in the property box:
Total Bytes: Aby
Number of bytes downloaded: BBY
Total Frames: AF
Frames downloaded: bf
Time Required: at
Actual time used: BT
%:loaded

And then a new layer, named as (this doesn't matter, but to form a good habit will be categorized, everyone later to see me put the source file, whether it is the layer name, or inside the library, I will be sorted out, many of the time will be set up the corresponding folder, so that you can find the source file inside the desired things, Point F6 Extend a keyframe
Then the first frame is written as:
A=getbytestotal (); b is defined as the total number of bytes downloaded
B=getbytesloaded (); A defines the total number of bytes that need to be downloaded
Loaded=int (b/a*100); A dynamic text box with a variable named loaded displays the percentage of bytes that need to be downloaded and the total number of bytes downloaded, but simply, it's a math, B divided by a and multiplied by 100.
Aby=_root.getbytestotal (); A dynamic text box with variable name Aby shows the total number of bytes that need to be downloaded
Bby=_root.getbytesloaded (); A dynamic text box with the variable named BBY shows the total number of bytes downloaded
Af=_root._totalframes; Displays the total number of frames for a dynamic text box with the variable named AF
bf=_root._framesloaded; A dynamic text box with the variable named BF shows the number of downloaded frames
At=int ((aby-bby)/(BBY/BT)) +BT); Displays the total time for the dynamic text box with the variable named at, which is also seen as a mathematical
Bt=int ((Gettimer ())/1000); The dynamic text box for the variable named BT shows the elapsed time, and 1000 is measured in milliseconds.
Then write the as in the second frame:
if (a==b) {//If the total number of bytes actually downloaded equals the total number of bytes that need to be downloaded then the next sentence
Nextscene (); Go to the next scene, that is, just like yesterday, you want to put the active painting in a scene under the loading scene
}else{//Other, that is, the above conditions can not be reached
gotoAndPlay (1); Go back and play the first frame, do a loop, download is not successful and do it again.
}
This is all done, we see as with mathematics is very related, int this statement is actually mathround simplification, and everyone in the second frame of the first line of the IF (A==B) attention must not be written a=b,= is assigned value, = = is equal to, we remember.


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.