I have loaded an external swf file which plays a flv file by default as swf is loaded. Now the problem is how do i remove the swf file from memory. my code :
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("ExternalSWF.swf");
myLoader.load(url);
detailMovieClip.movieHolder.addChild(myLoader);
I have tried many combinations of removeChild, unload and unloadAndStop but none works. I figure its all about not referencing correctly.
Hi Jah,
i understood your problem,i faced this problem many time but couldn't find correct solution.
I'm using now Event.REMOVED_FROM_STAGE. this method dispatch to parent swf for when the External swf removed from stage.
The sample example code below for the way of remove externalswf events:
parent swf actionscript code:
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("ExternalSWF.swf");
myLoader.load(url);
b_mc.addChild(myLoader);
a_mc.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void
{
a_mc.removeEventListener(MouseEvent.CLICK,onClick);
myLoader.unload();
b_mc.removeChild(myLoader);
myLoader=null;
}
ExternalSWF.swf actionscript code:
import flash.events.Event;
var num:Number=0;
addEventListener(Event.ENTER_FRAME,onRun);
addEventListener(Event.REMOVED_FROM_STAGE,onRemoveFromParent);
// remove all local events here//
function onRemoveFromParent(event:Event):void
{
trace("remove");
removeEventListener(Event.ENTER_FRAME,onRun);
}
function onRun(event:Event):void
{
num++;
trace(num);
}
Thanks/
North America
Europe, Middle East and Africa
Asia Pacific