4 Examples of pure as loading effect

Source: Internet
Author: User
A slightly larger flash file will have a loading pre-loading screen before playback. This takes into account the speed of the network, local browsing does not need to wait for download, but is uploaded to the Internet, because each user's network speed is different, it is necessary to add the loading image to our work. Before that, there have been many tutorials about the loading production method, today, we will tell the readers about the loading effect of four pure as products. Code Blind "you can even directly copy the code in the tutorial to your work. If you know the as code, you can read the code carefully and learn more about, or more as loading effects ...... Thanks to the author = cotton candy =, egg616, and Mr. Lang for providing the source code and ideas.

I. = cotton candy = loading tutorial

Relatively simple
Dynamically display load percentage
Copy all the code to the first frame. After the load is completed, the playback starts automatically.
Source code : Stop ();
_ Root. createtextfield ("myload_txt", 1, 0, 0, 0, 0 );
With (_ root. myload_txt) {// set the text
Background = true; // whether the text box has a background
Backgroundcolor = 0x336699; // background color of the text box
Textcolor = 0 xffffff; // text color in the text field
Type = "dynamic" // The text field is dynamic text
Selectable = false; // whether the text is optional
Autosize = "center"; // controls automatic size adjustment and alignment of text fields
_ X = stage. width/2; // the abscissa of the text field
_ Y = stage. Height/2; // ordinate the text field
}
Onenterframe = function (){
VaR loaded = _ root. getbytesloaded ();
VaR Total = _ root. getbytestotal ();
_ Root. myload_txt. Text = math. Floor (loaded/total) * 100) + "% ";
If (loaded = total ){
Onenterframe = NULL;
Removemovieclip (_ root. myload_txt );
Play ();
}
};

Ii. One of the loading art of egg616

1. Production principle:
All loading in the world can be divided into three parts:
1. Create a loop for updating data. Generally, there are two methods. One is to create two frames and generate a loop using the gotoandplay (1) command in the second frame. The other method is to only make one frame and generate a loop using the onenterframe command.
2. Use the getbytestotal () and getbytesloaded () commands to obtain the file data.
3. display the data obtained in step 2 as a graphic or animated image (usually expressed in text format)

The above description is very clear to a person who will do loading, but will not do it. I will probably not (haha). So next we will step by step, make a simple example (no text is displayed ):

2. Simple Example (there are only two steps, I believe you have the patience ):
I. Open your beloved animation, create a new scene, and drag it to the beginning.
Ii. Add the following as actions to the frame, that is, success!

Source code:

stop ();
function DR (Nam, de, D, Al) {
Na = createemptymovieclip (Nam, de);
Na. linestyle (D, 0x9900cc, Al);
Na. _ x = 160;
Na. _ y = 280;
Na. lineto (240, 0);
}< br> // a function for drawing a line. For details about the four parameters, see
onenterframe = function () {
var A = getbytestotal ();
var B = getbytesloaded ();
// obtain the downloaded data
If (B <) {
DR ("B1", 0, 30, 30);
DR ("B2", 1, 20, 30 );
DR ("B3", 2, 20,100);
B3. _ XScale = B/A * 100;
// draw three horizontal lines to display the download progress.
}else {
Delete onenterframe;
B1. removemovieclip ();
B2. removemovieclip ();
B3. removemovieclip ();
play ();
// After the download is completed, the image and function are deleted.
}< BR >};

You can press Ctrl + enter twice to perform the download test. If you have an as phobia, close your eyes and copy and paste it.

III. The loading Art II of egg616

1. Open the animation you want to add loading, create a new scene, and drag it to the beginning.
2. Add the following as code to the first frame of the scenario.

Source code: // copyright: Wu jiexing Lianjiang, Guangdong
// This work can be copied or modified at will, but please specify the original author
Stop ();
Sw = 550;
SH = 400;
//
Stage. showmenu = false;
// Hide the annoying right-click menu
Cs = 60;
// Mesh density
R = 2550;
D = r/Math. sqrt2;
// Curvature of the mesh
P = math. Pi;
// Define the constant pi
Createemptymovieclip ("ln", 1 );
Ln. linestyle (0, 0 xffffff );
For (VAR I = 1; I <= cs; I ++ ){
Ln. moveTo (SW/2 + R * Math. Cos (I/CS * P),-D + 300 + R * Math. Sin (I/CS * p ));
Ln. lineto (SW/2 + R * Math. cos (I/CS * P + p/2),-D + 300 + R * Math. sin (I/CS * P + p/2 ));
}
// Draw a gradient background below
Createemptymovieclip ("BG", 0 );
With (BG ){
Colors = [0x6666ff, 0 xffffff, 0x660099];
Alphas = [30, 30, 80];
Ratios = [0,100,200];
Linestyle (5, 0x00ff00 );
Matrix = {matrixtype: "box", X: 200, Y: 115, W: 50, H: 450, R: p/2 };
Begingradientfill ("linear", colors, Alphas, ratios, matrix );

MoveTo (-200-sw,-100 );
Lineto (200 + SW,-100 );
Lineto (200 + SW, 100 + SH );
Lineto (-200,100 + SH );
Lineto (-200,-100 );
Endfill ();
}
//
R1 = 50;
R2 = 170;
Nu = 32;
// Three parameters of the center circle, respectively;
Cr = 600;
// Cr is the fill radius
Createtextfield ("te", 5, 75,100,160,100 );
Te. textcolor = 0x9900ff;
// Create a text display download data
Function fo1 (Nam, de, RO ){
NA = createemptymovieclip (Nam, de );
With (NA ){
_ Y = 40;
Linestyle (0, 0x000000, 0 );
Colors = [0x6666ff, 0 xffffff, 0x660099];
Alphas = [130,130, 20];
Ratios = [0,120,200];
Matrix = {matrixtype: "box", X:-Cr/2, Y:-Cr/2, W: CR, H: CR, R: p/2 };
Begingradientfill ("RADIAL", colors, Alphas, ratios, matrix );
// Use as to fill in the gradient.
MoveTo (R1, 0 );
VaR BL = math. Cos (P/Nu );
For (VAR I = 1; I <= Ro; I ++ ){
Curveto (R1 * Math. cos (I * P/(Nu/2)-P/Nu)/BL, R1 * Math. sin (I * P/(Nu/2)-P/Nu)
/BL, R1 * Math. Cos (I * P/(Nu/2), R1 * Math. Sin (I * P/(Nu/2 )));
}
Lineto (R2 * Math. Cos (Ro * P/(Nu/2), R2 * Math. Sin (Ro * P/(Nu/2 )));
For (VAR I = Ro; I> = 1; I --){
Curveto (R2 * Math. cos (I * P/(Nu/2)-P/Nu)/BL, R2 * Math. sin (I * P/(Nu/2)-P/Nu)
/BL, R2 * Math. cos (I-1) * P/(Nu/2), R2 * Math. sin (I-1) * P/(Nu/2 )));
}
Lineto (R1, 0 );
Endfill ();
}
}
// This function is used to draw the middle ring, where the ring is made using the curverto method, which is not described here. I will detail it in the next tutorial.
Onenterframe = function (){
AB = _ root. getbytesloaded ();
BB = _ root. getbytestotal ();
// Obtain data
SB = int (AB/BB * Nu );
Fo1 ("Di", 4, Sb );
Di. _ x = 275;
Di. _ y = 200;
Di. _ yscale = 25;
Di. _ rotation =-30;
// Call the function as the ring above
Fo1 ("YZ", 3, Sb );
YZ. _ XScale = 100 * Math. Pow (3, 0.5)/2;
YZ. _ yscale = 25;
YZ. _ alpha = 30;
YZ. _ x = 275;
YZ. _ y = 360;
// Create a transparent ring below as the last shadow
If (AB >>>"
Di. onpress = function (){
Delete onenterframe;
Te. removetextfield ();
Di. removemovieclip ();
YZ. removemovieclip ();
Ln. removemovieclip ();
BG. removemovieclip ();
Play ();
};
}
};

4. Lang's as loading

1. Open the animation you want to add loading, create a new scene, and drag it to the beginning.
2. Create an empty Mc and drag it to the 1st frame of the new scene, and name its instance name as: SS
3. Add the following code to MC (in other words, click MC to open the as panel and enter the following code :)

Onclipevent (load ){
This. _ x = 180;
This. _ y = 300;
_ Root. Ss. createtextfield ("TT", 1, 70, 50,100, 20 );
_ Root. Ss. tt. textcolor = 0xff0000;
_ Root. Ss. createemptymovieclip ("louding", 2 );
With (_ root. Ss. louding ){
Linestyle (0, 0x0000ff, 0 );
MoveTo (0, 0 );
// Start point
Beginfill (0xff0000, 100 );
Lineto (0, 10 );
Lineto (10, 10 );
Lineto (10, 0 );
Endfill ();
}
_ Root. Ss. createemptymovieclip ("loudingk", 3 );
With (_ root. Ss. loudingk ){
Linestyle (0, 0x000000,100 );
MoveTo (0, 0 );
// Start point
Lineto (0, 10 );
Lineto (200, 10 );
Lineto (200, 0 );
Lineto (0, 0 );
}
}
Onclipevent (enterframe ){
Load = int (_ root. getbytesloaded ()/_ root. getbytestotal () * 100 );
_ Root. Ss. tt. Text = "loading" + LOAD + "% ";
_ Root. Ss. louding. _ width = 2 * load;
If (_ root. getbytesloaded () = _ root. getbytestotal ()){
_ Root. Play ();
}
}

TIPS: a simple method for testing the loading effect on the local machine

After Ctrl + enter, you often start playing the main animation without seeing the loading effect. to preview the loading effect clearly, a simple method is as follows: after Ctrl + enter, press Ctrl + enter again in the test animation playback state to clearly see the loading effect. In addition, you can change the speed of the analog modem. In the animation testing window, from the Debug menu, you can select a speed of 14.4, 28.8, 56 K, or custom.

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.