Hi,
Below is some code I am using to load 2 SWF into a main SWF. The first SWF loads and plays out and then is removed and is replaced with the second SWF that does the same thing. The problem I am experiencing, is that there are some blank frames during the transition from the first SWF to the second.
I would like to avoid this, as I am trying to create a whole movie using about 80 SWF’s and cannot afford to have blank frames between every scene.
var played:Boolean=false; // record of if the swf 'sc_08_sujoy.swf' has played yet
var my_Loader:Loader = new Loader();
my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, onLoadComplete);
my_Loader.load(new URLRequest("sc_02_shyamal.swf"));
my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, onLoadComplete);
var currentSWF:MovieClip;
function onLoadComplete(e:Event):void
{
my_Loader.contentLoaderInfo.removeEventListener(Ev ent.COMPLETE, onLoadComplete);
currentSWF = MovieClip(e.target.loader.content);
currentSWF.addEventListener(Event.ENTER_FRAME, onEnterFrame);
addChild(currentSWF);
}
function onEnterFrame(e:Event):void
{
if (currentSWF.currentFrame == currentSWF.totalFrames)
{
currentSWF.stop();
removeChild(currentSWF);
currentSWF.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
// if you want to get rid of it altogether
currentSWF = null;
my_Loader.unloadAndStop();
if(!played) // check have we loaded the second swf ? if not then load then second swf
{
my_Loader.load(new URLRequest("sc_08_sujoy.swf"));
my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, onLoadComplete);
}
played=true; // note that you have loaded your swf so this trigger is changed
}
}
Thanks!