8 Replies Latest reply on Nov 13, 2007 11:01 AM by kglad

    garbage collector does not work any way

    ex_manager
      when you unload some loaded swf file (Loaded with Loader class) it's Event Listeners continue their jobs
      is there anyway to solve this problem

      for example please made three files
      l1.fla , l2.fla , main.fla

      in l1 creat a MovieClip with instance name "symbol_mc"
      and type these code

      this.addEventListener(Event.ENTER_FRAME,test1,false,0,true);
      function test1(evt:Event){
      trace("l1");
      }
      symbol_mc.addEventListener(Event.ENTER_FRAME,test2,false,0,true);
      function test2(evt:Event){
      trace("symbol");
      }

      in l2 only create a text to see if file is loaded

      finally in main
      create to buttons with instance names btn1_btn and btn2_btn and add these codes

      var lo:Loader;
      var mc:MovieClip = new MovieClip();
      this.addChild(mc);


      function loadSomeFile(url:String) {

      lo= new Loader();
      this.addChild(lo);
      lo.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded);
      lo.load(new URLRequest(url));
      }




      function movieLoaded(evt:Event) {
      this.removeChild(mc);
      mc = MovieClip(lo.content);
      this.removeChild(lo);
      this.addChild(mc);
      lo=null;
      }
      btn1_btn.addEventListener(MouseEvent.CLICK,load1);
      function load1(evt:MouseEvent) {
      loadSomeFile("l1.swf");
      }

      btn2_btn.addEventListener(MouseEvent.CLICK,load2);
      function load2(evt:MouseEvent) {
      loadSomeFile("l2.swf");
      }

      create swf files l1 and l2 and then preview main
      first try btn1_btn and then try btn2_btn you will see after unloading l1 and loading l2 event listeners will continue their jobs!!!!!!!
      after loading l1 ev