Using LoadMovie can be dynamically loaded into external files, reducing the volume of the primary file, facilitating online downloading, and modifying, replacing the subfiles. If you have not done a Flash page, you can look at the basic composition of this Flash page, see
2-2-1
Just use the main files and subfiles in the figure, such as the FTP tool to your own space, you can easily implement only the main file, if you need to browse the subfiles, you can download it alone, you can think about it, if you Flash webpage is not divided, all unified Flash, made a few M or even more than 10 M, then who is willing to wait for the webpage? Unless yourself.
So it is very important to use LoadMovie. Let us start from the foundation and then analyze the specific questions involved in LoadMovie. There are two basic methods using LoadMovie: (1) Load the external SWF file into a layer. (2) Enter the external SWF file into a movie clip of the time axis. The use of these two methods is more intuitive. See the picture
2-2-2
The second method can be written in turn: _root.mc.loadmovie ("a1.swf"); if the suffix of A1 is then loaded, the external picture is loaded. Loading pictures is the same as loaded into the SWF file, will not be described. Speaking of the empty hole, make an example to see.
First, create a new folder, any name, such as: MyWangye
Second, make a flash released a SWF file and taking the name of the name, saved in mywangye, this A1 is the subfold we want to load.
Third, then do the master file, because we are the easiest, not painting, just in this main file, write loadingmovie ("A1.swf", 1), save this file in the MyWangye directory Take a name called Index
Fourth, the test effect, the source file is found in the packaged 01 folder after this article
Then use the second syntax in the above figure, continue to make one, pay attention, the second method needs to place an MC on the stage and take an instance name, or create an empty MC. After doing the above small experiment, can we conclude what conclusions? If you just get the following conclusion, it is too shallow. Let us think of: the coordinate problem of the external document being added; long-width problem; external file is relatively large, load delay problems; how to access the problem of SWF loaded; do not load, uninstall the problem .... If we don't study these problems, we will encounter a lot of trouble when you do a web page.
From the simplest loading of the above, we can get this conclusion: (1) If the loaded to the layer is loaded, the default registration point is the top left corner of the stage; if you load it into the MC, then the default registration point is The registration point of the MC. If the registration point of the MC is the upper left corner, the SWF file loaded is aligned with the upper left corner of the MC; if the MC's registration point is center, the loaded SWF is aligned with the center of the upper left corner with the center of MC. (2) The MC that is loaded will retain the original growth ratio.
Question 1: How to control the coordinates and growth ratios of the SWF file loaded?
Controls the loaded SWF file controls its long and width to adopt OnenterFrame, such as:
ON (PRESS) {
LoadMovie ("A2.SWF", "_root.mymc");
Oneterframe = function () {_root.mymc._x = 0;
_Root.mymc._y = 0;
_Root.mymc._width = 330;
_Root.mymc._height = 240;
}
}
Why use OneNterFrame? Because the process is loaded, there is a little delay, if there is no oneNters, then the statement is not read once, but after reading this time, it has not been loaded, so it will cause the coordinate size setting invalid. . Similarly, this is true if it is loaded on the layer.
ON (PRESS) {
LoadMovie ("A1.SWF", 1);
Oneterframe = function () {
_LEVEL1._X = 17;
_LEVEL1._Y = 30;
_LEVEL1._WIDTH = 330;
_LEVEL1._HEIGHT = 240;
}
}
Note these two methods, the first, load the external A2 into mymc, after coming in, A2 automatically replaces mymc, and we directly set the attribute of the MYMC set the properties of the SWF that is loaded. The second method, _Level is a reference to the movie loaded to the time axis, loading to the second layer is _level2; loading to the third layer is _level3.
Two Item: How to implement the click button to load an external SWF file, and display the downloaded download progress?
There are two ways to achieve this effect, one: Write the loaded Londing in the main file, the second, the loaded sub-SWF file has its own Londing. The description is now given.
One: Write Londing in the main file
The external sub-SWF file is named A1. There is a dynamic text box name to loadText, and a button is called BBT, and now LoadMovie and Londing are written.
_Root.bbt.onpress = function () {
_Root.createemptyMovieClip ("MC", 10);
Mc.LoadMovie ("a1.swf");
Mc._visible = false;
_root.bbt.onterframe = function () {
Var L = mc.getbytesloaded ();
Var t = mc.getbytestotal ();
Var getpercent = L / T;
LoadText = Math.Round (getpercent * 100) "%";
IF (l> 0 && l> = t) {
Mc._visible = true;
Delete this.onterframe;
}
MC._X = 10;
MC._Y = 10;
Mc._width = 440;
MC._HEIGHT = 320;
}
}
Second: There is your own londing in subfinies.
This way is the same as the previous Londing, just pay attention to a question is the problem of paying the path, such as writing:
First
Loaded = getBytesloaded ();
Total = GetBytestotal ();
LTS = Math.Round ((loaded / total) * 100);
Wenben = lts "%";
Second
IF (lts == 100) {
GotoAndStop (3);
} else {
GotoandPlay (1);
}
And the comparison introduced in the previous londing, didn't you see the difference? Just getting off _root After loading, the external SWF file is equivalent to one of the MC in the main file _root is to point to the main file _root, of course, the error will be displayed.
Question 3: I want to draw a screen on the stage, then click on a button to load an external SWF to play what to do?
Then let's make a photo album together. When the primary file is loaded, click the button to load an external SWF file and have a londing display. First we have the following preparations: (1) Prepare a few pictures, now we will prepare 7, 6 sub-files, the main file is used. (2) The main file stage size is set to 770 * 420 in order to adapt to the needs of the web page. The subfield stage size is set to 512 * 384, so it doesn't matter if it is loaded, it controls the size, it is convenient (in fact, we should like this, save some trouble.
First, make subfiles. Each is used to display pictures, the first and second prome to write Londing, third from ~~ 20, according to his hobby, do something brightness, to generate dynamics, and finally write STOP (). The first and second power of the Londing are as follows
First
Loaded = getBytesloaded ();
Total = GetBytestotal ();
LTS = Math.Round ((loaded / total) * 100);
Wenben = "Data Download" LTS "%";
Second
IF (lts == 100) {
GotoandPlay (3);
} else {
GotoandPlay (1);
}
In this way, there is 6 manufacturing materials, named B1 ....b6, respectively, is published as a SWF file. Save in a folder.
Second, make a main file
The first is used to write Londing, and the second fluid is something like the screen, and the button, in order to increase the effect, put a music on the timeline.
The first londing // is not described above because of much,
STOP ();
i = 0;
Oneterframe = function () {
// Use the constant triggering event
Loaded = _Root.getbytesloaded ();
Total = _Root.getbytestotal ();
Var aa = math.round ((loaded / total) * 100);
_Root.dongtai.wenbens = aa "%";
_root.dongtai._x = 188 aa * 3;
_Root.bb._width = aa * 3;
IF (aa> = 100) {
// Take out that the condition is jumped out, otherwise it will continue to circulate
_Root.gotoAndStop (2);
Delete this.onterframe;
// The purpose of using Delete is to destroy the OnNternterFrame event after downloading to save resources.
}
}
2nd button on the button
ON (PRESS) {
_Root.i ;
IF (i == 7) {
i = 6;
}
LoadMovie ("B" i ". SWF", "_root.mc");
_root.tishi = "Part I " Zhang Picture ";
Tell the lazy, it will not make a detailed demonstration, and we can use a long statement to achieve the same effect, which is a concentration of AS.
Please refer to the original file in the case.
Question 4: I want to load multiple external files again. When the first load is played, immediately load the second, and after the second play is over, it will be loaded into the third, ... .. end. How to do?
First of all, we must first ask questions, what is the meaning? In this way, it is better to do all SWF as all, because each time you call an external SWF, you need to wait for a certain time to wait for the download. Of course, if you want to make a series, after playing, use the Londing screen of Londing's next episode "Loading the next set, please wait" then or can.
The method is very simple: according to the original file of the problem, slightly modify, remove a button, use a button to load the first, and then the last one can put a function in the main file.
Button:
ON (PRESS) {
LoadMovie ("B1.SWF", "_root.mc");
}
Master file definition function
Function Go2 () {
LoadMovie ("b2.swf", "_root.mc");
}
Function Go3 () {
Loadmovie ("b3.swf", "_root.mc");
}
Function Go4 () {
LoadMovie ("b4.swf", "_root.mc");
}
Function GO5 () {
Loadmovie ("b5.swf", "_root.mc");
}
Function Go6 () {
LoadMovie ("b6.swf", "_root.mc");
}
The first B1 SWF's last _root. Go2 (), the last one of the second external SWF _Root.go3 () ......... ..