Capturing Movie Unload Event


I am using Flash 8 and have been trying several ways to capture the event that occurs when a higher level movie is unloading.

For Example:

I have a parent_movie.swf running on _level0 which loads child_movie.swf using loadMovieNum(“child_movie”,2) placing it on _level2.

I have a function on parent_movie.swf “stopMainSound”. It calls _level0.mysound.stop(“01”). There is another function called “startMainSound”. It calls _level0.mysound.start(“01”).

When child_movie.swf loads one of the first actions coded is "_level0.mysound.stop(“01”). This works fine. However, I have tried to capture an event when child_movie.swf unloads to call “startMainSound”. I tried coding:

_level2.onUnload = function(){
trace(“I made it!!!”);

Of course, it never made it to this function and I cannot figure out why. Any help would be very much appreciated.

Kind Regards,
James Davis


_level2.onUnload = function(){
trace("I made it!!!");

since starmainSound is a function you need to put those perenthesis


ActionScript Code:

[FONT=Courier New][LEFT]_level2.[COLOR=#0000ff]onUnload[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p>trace[COLOR=#000000]([/COLOR][COLOR=#ff0000]“I made it!!!”[/COLOR][COLOR=#000000])[/COLOR];</p>



Thanks for the reply. I would agree about adding the parentheses after startMainSound, however, it is never making it to the function because the trace message is not getting displayed in the Output window when I run it. Or is this just supposed to be a pointer and the trace would never get called anyway?

where is this action residing in a frame on the main timeline? maybe having a look at your fla will solve the problem because if its not outputting the trace your either stopping the timeline or something else before ti gets to the unload action

It is getting unloaded by parent_movie.swf. When parent_movie.swf needs to load child_movie.swf, it immediately calls unloadMovieNum(2) which removes the child movie. I thought that this action would trigger the _level2.onUnload event in the child movie. Does it not get fired in this scenario? How should I make this happen?

Best Regards,
James Davis

Why dont you use moviclip holders instead of using levels you have much more control and its way better. like I said before I’d have to see your flas in order to see what really is the problem :-/

This is a template that I have been making edits on. I am assuming the only reason that it does not use movieclip holders is because of performance reasons? The individual movie file sizes can get out of hand.

Both of the .fla’s are too big in size to upload here. Is there an easy way in Flash 8 to save you a scaled down version that I am not aware of? If I can get them sized down, I could attach them here.

James D.

You can host your flas on your site and using movieclips is the best way it doesnt affect performance in anyway its the norm for external content.

Thanks Grimdeath for you help. I ended up creating a movieclip holder to load my mp3 player swf page. And it does give me more available events to use.

I am still having issues getting the onUnload event to fire. It is probably an issue revolving around using an incorrect Z-Order. Trial and error!

Thanks Again,
James D.