Skip navigation
Currently Being Moderated

remove external swf file

Aug 9, 2012 10:29 PM

Tags: #as3

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.

 
Replies
  • Currently Being Moderated
    Aug 9, 2012 11:31 PM   in reply to jahflasher

    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/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points