In the Forum technology area to stay so long, found that for these two functions we ask more frequently, today is here combined with my own experience, detailed writing a tutorial, I hope to give you later use to bring help.
One, Loadmovie ("url", Target [, Method])
Description: function; Loads the SWF file or JPEG file into the path of the target movie clip in Flash player while playing the original SWF file.
First we can see that the function has 3 parameters: URL, Target, method. Where the last parameter "method" is an optional parameter.
1. Parameter URL: The absolute or relative URL (path) of the SWF file or JPEG file to be loaded.
This means that the URL can be a local file path, or it can be a file address on the Internet. However, you can only be a SWF or JPEG file, regardless of where you load it. And, the argument is a string, so it must be written in a half-angle double quote--
Loadmovie ("01.swf", _root)
Loadmovie ("01.jpg", _root)
Loadmovie ("http://www.abc.com/01.swf", _root)
Loadmovie ("01.jpg", _root)
......
2. Parameter target: The path to the target movie clip. The target movie clip will be replaced with a loaded SWF file or image.
This parameter represents the path to which the movie will be loaded, and it points to the path of the target movie clip. When loaded, the target movie clip is replaced with a loaded SWF file or image. ——
Loadmovie ("01.swf", _root)
Loadmovie ("01.swf", _root.loading)
Loadmovie ("01.swf", _root.loading.01)
......
3. Parameter method: Optional parameters that specify HTTP methods for sending variables. The parameter must be a string get or POST. If there are no variables to send, this argument is omitted. The Get method appends a variable to the end of the URL, which is used to send a small number of variables. The POST method sends a variable in a separate HTTP header, which is used to send a large number of variables.
Second, loadmovienum ("url", level [, variables])
Description: A function that loads a SWF file or a JPEG file to a level in Flash player while playing a previously loaded SWF file.
First we can see that the function has 3 parameters: URL, target, variables. Where the last parameter "variables" is an optional parameter.
1. Parameter URL: The absolute or relative URL (path) of the SWF file or JPEG file to be loaded.
This parameter of the function is identical to the usage of this parameter in Loadmovie above, and is no longer explained here.
2. Parameter level: An integer that specifies which levels of the SWF file will be loaded into Flash Player.
When loading, you can write this:
Loadmovienum ("01.swf", 1);
Loadmovienum ("01.swf", 2);
Loadmovienum ("01.swf", 3);
......
Control, you can use this:
_level1._x=10
_level2.aa._alpha=50
_level3.aa.bb._width=110
......
It should be noted that each level can only have one SWF or JPEG file at a time. If two SWF or JPEG files have the same level, the latter replaces the former. Different levels of _level, the level of large will be covered by the small, that is: the number of large will be in the number of small.
3. Parameter variables: Optional parameter specifying the HTTP method used to send the variable. The parameter must be a string get or POST. If there are no variables to send, this argument is omitted. The Get method appends a variable to the end of the URL, which is used to send a small number of variables. The POST method sends a variable in a separate HTTP header, which is used to send a large number of variables.
Third, the positioning of the loadmovie/loadmovienum ...
Positioning of 1.loadMovie
Because the SWF or JPEG file loaded in with Loadmovie is finally placed in the target movie clip, we can control the target movie clips that are loaded into the _x and _y as the MC. It's as if we hung a frame (the target movie clip) on the Wall (_root), and then put (load) a photo (SWF or JPEG file) in the frame, and when we want to move the position of the photo, we can just shift the position of the frame.
For example, in the home scene there is an instance of the MC named AA (Coordinates (20,30)), we want to load a 02.swf file inside, and to load this into the frame (_ROOT.AA) in the photo (02.swf) appears in the Home View (_root) coordinate system (50,100) Secretariat The code is as follows:
PHP Code:Loadmovie ("02.swf", _root. ) AA );
_root . AA . _x = - M ;
_root . AA . _y = - ;
In practice, it is more likely to use as to create an empty MC and then load an external SWF or JPEG file in this MC. The code is as follows:
PHP Code:_root . Createemptymovieclip ("AA", 1);
with (aa) {
_x = - M ;
_y = - ;
Loadmovie ("02.swf");
}
Positioning of 2.loadMovieNum
As we know from the front, the function loadmovienum is to load the SWF or JPEG file into the _level (level). and is used _level1._x, _level2._x, _level1.aa._x and so on to locate. For example, to load 02.swf into the main scene coordinate system (50,100), the code is as follows:
PHP Code: loadmovienum("02.swf", 1);
_level1 . _x = - M ;
_level1 . _y = - ;
But in the test, you will find that the loaded 02.swf did not appear as we expected in the Home View coordinate system (50,100) position, this is why?
Originally, in the absence of the use of Loadmovienum before, all graphics, MC, etc. are in the _level0, we usually use the _root is actually _level0. You can make a test: trace (_root==_level0), you will find that the return value is "true".
Then, when we use Loadmovienum to load the SWF or JPEG file, the program will create the _level you specify, then load the SWF or JPEG file immediately thereafter. If, as in the code, it is not judged whether _level exists and calls its properties, it is bound to be reactive.
The solution is also very simple, that is, to use a loop to determine whether the specified _level exists. Once _level is produced, its properties can naturally be invoked. The code is as follows:
PHP Code:Loadmovienum ("02.swf", 1);
Onenterframe = function () {
if (_level1) {
with (_level1) {
_x = - M ;
_y = - ;
}
Delete Onenterframe ;
}
};
Or:
PHP Code:Loadmovienum("02.swf", 1);
function Go() {
if (_level1) {
with(_level1) {
_x= - M;
_y= -;
}
clearinterval(fps);
}
}
fps= setinterval( Go);
Or you can use the Moviecliploader class in Macromedia Flash MX 2004 to determine the loading status. (The specific use of the way to see related tutorials)
Reproduced in the Semitic empire, author: Cotton Candy |