Posted By

jaredyeo on 11/08/10


Tagged

collection gc garbage Systemgc


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

romainsauger
sexyflash
tspitzr
dubogii


AS3 Loader Garbage Collection


 / Published in: ActionScript 3
 

URL: http://simplistika.com

  1. import flash.display.Loader;
  2. import flash.utils.Timer;
  3. import flash.events.TimerEvent;
  4. import flash.system.ApplicationDomain;
  5. import flash.system.LoaderContext;
  6. import flash.system.System;
  7. import flash.net.LocalConnection;
  8.  
  9. var t : Timer = new Timer(500);
  10. var l : Loader = new Loader();
  11.  
  12. var lc : LoaderContext = new LoaderContext();
  13. lc.applicationDomain = new ApplicationDomain();
  14.  
  15. t.addEventListener(TimerEvent.TIMER, fOnTimer);
  16. t.start();
  17. addChild(l);
  18.  
  19. function fOnTimer(e : TimerEvent) : void
  20. {
  21. if (l.content != null)
  22. {
  23. l.unloadAndStop();
  24. System.gc();
  25. System.gc();
  26. try {
  27. new LocalConnection().connect('gc');
  28. new LocalConnection().connect('gc');
  29. } catch (e:*) {}
  30. }
  31. else
  32. l.load(new URLRequest("Lighthouse.jpg"), lc);
  33. }

Report this snippet  

You need to login to post a comment.