remove external swf file


i have loaded external swf file plays flv file default swf loaded. problem how remove swf file memory. 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 , unloadandstop none works. figure not referencing correctly.

hi jah,

i understood problem,i faced problem many time couldn't find correct solution.

 

i'm using event.removed_from_stage. method dispatch parent swf when external swf removed stage.

 

the sample example code below 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 local events here//

function onremovefromparent(event:event):void

{

    trace("remove");

    removeeventlistener(event.enter_frame,onrun);

}

 

function onrun(event:event):void

{

    num++;

    trace(num);

}

 

thanks/



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support