PDA

View Full Version : Loading movieclips sequentially using a single container


mylola
09-20-2006, 12:27 PM
I tryed to use this script to load movie clips using an empty movie clip as a container.

My script:
________________________
this.createEmptyMovieClip("my_mc", 0);

my_mc.createEmptyMovieClip("container_mc",99);

var my_mcl:MovieClipLoader = new MovieClipLoader(file.swf,1);

my_mcl.loadClip("file1.swf", my_mc.container_mc);

my_mc1.loadClip("file2.swf", my_mc.container_mc);

my_mc.onPress = function():Void {
trace("It works");
};_____________________________

The idea is to have them play one after the other (file1.swf, followed by file2.swf), but I had no success. :mad: When testing the movie, it launches the file2.swf and then go on looping it. No signs of file1.swf!
Can anyone help me with this?

kool-Aid
09-20-2006, 08:24 PM
do they have to run sequentialy w/o any user action? Have you considered Combining the movie clips to make one?

mylola
09-21-2006, 09:14 AM
Movieclips have to run sequentially and without any user action.
:( Combining them in a single movie is not a reasonable option, as the combination of movieclips may be modified almost every day.
Can you tell me what am I do wrong, or what I must do to make it work?

kool-Aid
09-21-2006, 04:52 PM
Movieclips have to run sequentially and without any user action.
:( Combining them in a single movie is not a reasonable option, as the combination of movieclips may be modified almost every day.
Can you tell me what am I do wrong, or what I must do to make it work?

Well i can tell you that the reason that code is not working is because Your image holder was told to load your first file, then your second file. You didn't tell it when to load the second one. So your image holder just does it imediately.
Are the files you want to swap swf?(just wondering if you could script the file itself to swap, or swith)

I know there is a command to do what you want to do with video with sound. It is

onSoundComplete

I dont know the command for video, but that's what you need to do so that your image holder knows when to perform your action. Sorry i can't help more.

kool-Aid
09-22-2006, 06:07 PM
I was browsing the action script forum and this was posted by
User- SkyNarc
I think this post shoul help you out.

loadMovie function
loadMovie(url:String, target:Object, [method:String]) : Void
loadMovie(url:String, target:String, [method:String]) : Void


Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8. If you load an animated GIF, only the first frame is displayed.

Tip: If you want to monitor the progress of the download, use MovieClipLoader.loadClip() instead of this function.

The loadMovie() function lets you display several SWF files at once and switch among SWF files without loading another HTML document. Without the loadMovie() function, Flash Player displays a single SWF file.

If you want to load a SWF or JPEG file into a specific level, use loadMovieNum() instead of loadMovie().

When a SWF file is loaded into a target movie clip, you can use the target path of that movie clip to target the loaded SWF file. A SWF file or image loaded into a target inherits the position, rotation, and scale properties of the targeted movie clip. The upper left corner of the loaded image or SWF file aligns with the registration point of the targeted movie clip. Alternatively, if the target is the root Timeline, the upper left corner of the image or SWF file aligns with the upper left corner of the Stage.

Use unloadMovie() to remove SWF files that were loaded with loadMovie().

When using this function, consider the Flash Player security model.

For Flash Player 8:

Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox.
Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local.
Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
Movie clips in the local-with-file-system sandbox may not script movie clips in the local-with-networking sandbox (and the reverse is also prevented).
For Flash Player 7 and later:

Websites can permit cross-domain access to a resource by means of a cross-domain policy file.
Scripting between SWF files is restricted based on the origin domain of the SWF files. Use the System.security.allowDomain() method to adjust these restrictions.
For more information, see the following:

Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash
The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security
The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/fp8_security_apis
Availability: ActionScript 1.0; Flash Player 3 - The ability to load JPEG files is available as of Flash Player 6. The ability to load unanimated GIF files, PNG files, or progressive JPEG files is available as of Flash Player 8.

Parameters
url:String - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///.

target:Object - A reference to a movie clip object or a string representing the path to a target movie clip. The target movie clip is replaced by the loaded SWF file or image.

method:String [optional] - Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Example
Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage:

loadMovie("circle.swf", mySquare);
// equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare);
// equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare");


The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the mySquare movie clip:

loadMovie("circle.swf", this);
// Note that using "this" as a string for the target parameter will not work
// equivalent statement (Usage 2): loadMovie("circle.swf", "_level0");


The following loadMovie() statement loads the SWF file sub.swf from the same directory into a new movie clip called logo_mc that's created using createEmptyMovieClip():

this.createEmptyMovieClip("logo_mc", 999);
loadMovie("sub.swf", logo_mc);


You could add the following code to load a JPEG image called image1.jpg from the same directory as the SWF file loading sub.swf. The JPEG is loaded when you click a button called myBtn_btn. This code loads the JPEG into logo_mc. Therefore, it will replace sub.swf with the JPEG image.

myBtn_btn.onRelease = function(){
loadMovie("image1.jpg", logo_mc);
};


Usage 2: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage:

loadMovie("circle.swf", "mySquare");


See also
_level property, loadMovieNum function, loadMovie (MovieClip.loadMovie method), loadClip (MovieClipLoader.loadClip method), unloadMovie function