AS3 – loader(), unload(), bastardload()


So here I am working on a sweet project with PV3d and a couple of components I’ve created a while ago (AS2), the task is simple, Inside of an AS3 project load up external swf’s (AS2) and unload them ondemand. Sounds simple? Well it isn’t, after doing some tests, I’ve came across a few “nice” conclusions,

  • as Adobe recommends you shouldn’t mix AVM1 & AVM2 projects
  • The loader method works great and I really like the new coding with AS3
  • hmmm… I can’t unload my newly loaded swf properly
  • Garbage collector doesn’t pick up the discarded objects

so yeh, I’m using 4 “equal” swf’s with different static content but with the same code inside, now when I load up 2 of them they start to bug eachother, as they are running the same code which is not being separated properly, I’m not sure if that can even be done in another situation but as soon as you load 1 external swf, unload it, the code which has been active during the runtime of that swf IS STILL ACTIVE even after the unload event… buggers..

I’ve found a few blogs posting about this issue as well someone opened a bug on Adobe’s bug reporting central, but I wasn’t able to find any solution. Do you guys have something up your sleeve? If the Answer is YES!! Please Please let me know!!

Meanwhile I’ll be recoding my components to AS3, which will not lead to a solution but then it’s anyway done for future projects.

by the way, the hint with setting loader = null; doesn’t work really as the GC is still not picking up discarded data.

,

  1. #1 by edzis on May 9, 2008 - 10:11 am

    You might want to check out http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html – Grant Skinner provides some workarounds.

  2. #2 by Tiago on May 11, 2008 - 1:00 am

    edzis, thanks for that hint man.. I finally solved one of the issues.

  3. #3 by saran on November 9, 2009 - 3:15 pm

    hi
    I am having doubt in swfloader in flex 3….i am using two swf files i.e adobe presenter file..i want to run it in my application.but my problem is only one file is playing other one is not playing….could you know how to unload the previous content in that swfloader

  4. #4 by Ruth on February 11, 2010 - 3:39 am

    I’m having the same problem unloading my swf’s.

(will not be published)