all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

Determine current frame of external swf loaded into movieclip


Determine current frame of external swf loaded into movieclip especht
1/27/2005 9:30:44 PM
flash actionscript:
I have created a movie that loads external SWFs into an existing movie clip. I
need to know when the external swf has completed playing so I can remove it. I
have tried using the following:

mcSwapableClip.onEnterFrame = function() {
trace(mcSwapableClip._currentframe);
if (this._currentframe == this._totalframes){
trace("clip ended");
}
}

However, this isn't working. this._currentframe and
mcSwapableClip._currentframe are always 1. I am guessing this is showing the
frame of the holder clip, not the external swf.

I've also tried creating a global function and adding an event to the final
frame of the external movie to call the global function. When I try just
calling the global function from the external file, nothing seems to happen.
I've also tried calling _parent.functionName, but I get an error about sandbox
security.

I'd prefer to be able to determine the end of the clip using the onEnterFrame
function (but if noone has the answer to that, I'd be interested in hearing how
to do it by having the external file call a function on the main timeline).
Please let me know if you have any ideas on how to do this.

Thanks,

Erich
Re: Determine current frame of external swf loaded into movieclip jlamberes
1/28/2005 1:50:54 AM
Erich,

My guess is, that if you want this._currentframe to ever be anything more than
one, it must start out being an emtyclip.

In other words load you external swf's into an empty clip using the
createEmptyMovieClip.

This should help you out...

var myMCL = new MovieClipLoader(); //create an instance of MovieClipLoader

myMCL.onLoadInit = function (targetMC) { //loading done
checkClip();
}

this.createEmptyMovieClip("mainClip",30);
mainClip._x = 0;
mainClip._y = 0;

//this triggers loading
myMCL.loadClip("any.swf", mainClip);

function checkClip() {
this.onEnterFrame = function() {
if (mainClip._currentframe == mainClip._totalframes) {
trace("Its finished")
delete this.onEnterFrame;
} else {
//continuing function can go here
}
};
}

Hope that helps
Re: Determine current frame of external swf loaded into movieclip especht
1/28/2005 5:31:15 PM
AddThis Social Bookmark Button