unloadMovie help... please

Hi I have a question about the load/unloadMovie commands.

I have a movie, with a second movie loaded into a section of it. I was wondering if it is possible to have an action inside this loaded movie that tells the main movie to unload it and go to the next frame.

I tried doing it like this:

I put

loadMovieNum(“second.swf”, 5);
stop();

in the main timeline, with unloadMovieNum(5); on the next frame, then in the loaded movie I put:

tellTarget (“mainmovie.swf”) {
nextFrame();
}

on the last frame, which I thought would cause the main movie to unload the second movie and continue the animation.

Instead, I get this error when I publish:

Target not found: Target=“21.swf” Base="_level5"

and I am stumped.

Any help at all would be incredible appreciated. Also please bear in mind that I am pretty new to actionscript, so if you could spell it out for me that would be great.

Thanks to anyone who can help me out,

Matt Booth

unloading _level0 unloads everything above it i believe. for example to completely change your main movie, simply load another one into _level0 and all levels will be unloaded.

why don’t you just have a _level0 that does this:

loadMovieNum(“firstAnimation.swf”,2);

load your second movie onto _level5…
loadMovieNum(“secondAnimation.swf”,5);

then when the first animation is done just unloadMovieNum(2); this will get rid of the first scene. you can use a bunch of levels…

if you want to add advanced options to the movies you are loading such as being able to position them, rotate, scale, etc…
load the movie into a movie clip instead of a level. make an empty movie clip, instance name = “mc”. then when you are ready to load a movie into it, loadMovie(“myMovie.swf”,“mc”);
this will load the movie into the movie clip. you can easily position it scale, etc.

bottom line… use _level0 as a controller… load movies onto upper levels or into movie clips… either way you will be able to load and unload them easily


[email protected]

Thanks so much for the incredibly quick reply.

What I was actually trying to do was have a button in the second movie that would jump to a closing animation in the second movie, then have that second movie unload itself somehow.

Since the second movie is not a fixed length, but rather I want it to close when the user pushes a button, I don’t think I can just unload it from a level_0 at a certain point in time. I think I need to have an action in the second movie that says “after the user has pushed the close button (in the second movie), and the closing animation has finished (also in the second movie), THEN unload the second movie”.

The only thing I could think of that might work would be to use tellTarget to make the first movie unload the second one after the button is pushed in the second one, but as I said before I’m pretty new and don’t know all that well what’s going on.

Maybe I just don’t really understand your advice.

I would be very grateful for any further help.

Matt Booth

here is example:

https://www.circol.net/examples/loadUnload.zip

this should help i think. good luck


[email protected]

Right click the mouse on the frame you want to unload and select actions from the drop down list, once in the actions box click the action tab then browser/Network…you will then see the loadmovie funtion and the unload movie function. when you load your 2nd movie into the main movie load it into level1, when you want to unload it use the unload funtion in the actions box, make sure your in normal mode not expert…then type in 1 where it ask you the level you want to unload…hope this helps! Jesse H

or you can try the quit function in the actions box, put this function in your second movie at the end, it may work I havent tried it, good luck JesseH

Hi guys.
Even after all your generous and appreciated help so far, I still can’t get it to do what I want it to. The problem is that upon unloading the second movie from inside the first, I want to first to advance to the next frame.

Since I don’t think I’m explaining myself very well, I put the two movies online at

http://www.twnty1.com/flash/flash.html

If you could take a look and let me know what I’m doing wrong I would be much obliged.

Thanks again,

matt booth

when movie 2 loads up… tell it to make the parent movie that loaded it, i am guessing level0 play.

put this in one of the frames in movie2:

tellTarget("_level0") {
play();
}
this will make it play next frame and keep going

or

tellTarget("_level0") {
nextFrame();
}

this will make it stop on next frame

Awesome! It works!

Thanks a lot for putting up with me.

matt booth

This thread has been invaluable. But I have another situation.

Here is my structure of movies:

start.swf
1 frame w/ loadmovie(“preload.swf”); stop();

preload.swf
various graphics, load bar, and an MC named host
some of the load code:

host.loadMovie(“main.swf”, 4);
function preload(theClip) {
if (!theClip.doneLoading) {
if (theClip._framesloaded>0 && theClip._framesloaded == theClip._totalframes) {
gotoAndPlay(“Enter”);
} else {
theClip.stop();
}

Then on load host clips starts playing.

Since I am actually loading the movie clip into ‘host’ it doesn’t actually load to level4 right?

Because in level4 I try to unload level2 but everything goes black.

I am stuck with my limited script knowledge. I think I have to load the movie to ‘host’ so it can get the name to check for framesloaded.

The MC host has the following script inside it:

onClipEvent (enterFrame) {
if (this._url != _root._url) {
_root.preload(this);
}
}

Please help! I just want to unload the preloader and play main.swf on another level.

RR