Let's take a look at the code and its analysis ::
Stage. showMenu = false; // right-click the screen to block the Stage. scaleMode = "noBorder"; // The player has no menu Stage. scaleMode = "noScale"; // disable scaling // The above code is just a personal hobby. This. createEmptyMovieClip ("preloader", 10000); this. createEmptyMovieClip ("mc", 10001); // dynamically create a mc to load the image mc. loadMovie ("test.jpg"); // load an image named test (in jpg format) mc. _ visible = false; // The shader mc is invisible/* ------------------------------------------------ preloader. onEnterFrame = function () {var l = mc. getBytesLoaded (); var t = mc. getBytesTotal (); var getPercent = l/t; loadText = Math. round (getPercent * 100) + "% completed"; // var: loadTest loadBar in a dynamic text box. _ width = getPercent * 100; // The length of the progress bar. In the home scene, its instance name: loadBar if (l> 0 & l> = t) {mc. _ visible = 1; delete this. onEnterFrame; // make mc visible after loading, and stop loop (delete this. onEnterFrame;)} */---------------------- This code is used to determine the loading status. // compile MovieClip. prototype. jump = function (scale, frequency, quotiety) {// three parameters: scale -- image ratio frequency --- elastic frequency quotiety --- elasticity coefficient this. tempo + = (scale-this. _ xscale) * frequency; this. tempo * = quotiety; this. _ xscale = this. _ yscale + = this. tempo; // place the image in the middle of the scene (550X400) this. -x = 275-(this. _ width/2); this. _ y = 200-(this. _ height/2 );
}; // -------- Set the image's elastic effect. You can use this effect in other aspects, such as buttons.
// ----------- Determines the mouse event. When the mouse and image collide, the user-defined function is called and assigned a value to mc. onEnterFrame = function () {if (this. hitTest (_ root. _ xmouse, _ root. _ ymouse, true) {this. jump (70 ,. 9 ,. 6);} else {this. jump (30 ,. 6 ,. 5 );}}};
The above code is in the first frame of the main scenario.
Manually create MC, draw a line, and use it as a progress bar to pull MC from the library to the main scenario, instance name: loadBar. Create a dynamic text box in the home scene to display the loading percentage. var: loadText
Postscript:After loading, you can use the function.
So pay attention to the judgment of loading. This is especially important when loading external files.