Flash Player 9 has a very dirty secret. It doesn't even try hide this dirty secret, but it's still not that widely known. You see, Flash Player has severe problems with separation anxiety - once it's loaded some content, it has a really hard time ever letting it go. Technically speaking, it is extremely difficult to make Flash Player 9 unload ActionScript 3 content.
In this article, I'll take an in-depth look at the issue, it's implications, suggestions for addressing the problem in the player, and some workarounds for the time being. If this issue seems like it will impact your projects, I'd strongly encourage you to read through the article and educate yourself, then use the link at the end of the article to provide Adobe with feedback on it. Likewise, I would encourage you to share this issue with other developers, both to help spread awareness of the issue, and to give them the opportunity to also provide feedback to the Flash Player team. I see this as one of the most critical issues that should be solved in Flash Player 10, and the more people raise it as an issue with Adobe, the more likely it is to be addressed.
In my opinion, this issue breaks down into three problems: A major player bug, content sandboxing, and explicit unload functionality. Note that these issues affect content created with both Flex 2/3 and Flash CS3.
Background
First, a little bit of info on the AVM2 garbage collector for those who haven't read my previous articles about resource management in player 9. With ActionScript 2 content, calling MovieClip.unloadMovie() explicitly removes the contents of a MovieClip. This meant that your loaded content would immediately stop executing, and be removed from memory.
In AS3, calling Loader.unload() simply removes the reference to the loaded movie. If any other references exist to the loaded content, it will not be unloaded. Even when all references are removed, it only frees the content for collection by the garbage collector at some indeterminate point in the future. This means that even if everything worked as expected the loaded content will continue to execute, and remain in memory for an indeterminate amount of time after you unload it. This is problematic in many ways, but it is made worse by a bug in the player.
Flash Player 9 Bug
Flash Player 9 has a critical bug that prevents unloading loaded SWFs that have any active ENTER_FRAME or TIMER event listeners. This occurs regardless of whether these listeners are all within the scope of the loaded SWF, or even if they all use weak references. This also affect timeline code written in Flash authoring - if you have any code in your timeline, it will not be possible to unload that SWF.
Content Sandboxing
AS3 lacks any support for explicit content sandboxing. By this, I am referring the ability for a developer to load a SWF into a sandbox, so that the loaded content can't reach back into the loading application. This would be a very useful for a number of reasons, including loading third party modules or plug-ins without having to worry about them messing with things in your application. More important to this article though are the implications on unloading loaded content.
Firstly, content sandboxing would allow a developer to prevent a loaded SWF from adding listeners outside of its scope. This is important, because developers rely on stage events in AS3 for notification of things like global mouse movements, and key presses, but creating a stage listener from a loaded SWF will prevent it from ever being unloaded (unless it uses weak referencing). This is because addEventListener creates a reference back to the listener from the event dispatcher (in this case, the stage). This means that your content might never unload, and it means that third party content can (intentionally or not) prevent itself being unloaded by simply adding a stage listener.
Secondly, content sandboxing would allow the player to keep loaded content in a nice clean package, which I imagine would make explicit unloading possible.
Explicit Unloading
As outlined in the background section, there is no way to explicitly unload loaded SWFs in AS3, which was very simple in AS2. There is a good reason for this – content can be referenced, instantiated, and re-parented across SWF boundaries in ActionScript 3. This makes unloading content much more complicated than it was in ActionScript 2. Still, the lack of this capability is a major downgrade from AS2, and makes some types of projects nigh on impossible.
I believe that content sandboxing would help address this issue, making it much easier to remove loaded content. Adobe could restrict the ability to explicitly unload SWFs to sandboxed content. For most applications that rely on loading and unloading content dynamically (galleries, for example) this would be an adequate solution.
Implications
These issues have some major implications, that affect three types of projects in particular:
- Gallery or portfolio projects. Some of you may have noticed that incomplet.org stagnated as soon as AS3 was released. This is because it's virtually impossible to create a site like incomplet.org in AS3. Because loaded content cannot be easily unloaded, it would mean that experiments would continue to run in the background after users clicked off of them. The whole site would slow to a crawl, and eventually crash. Not good. This is also the reason that in my upcoming FitC talk, I will likely have to resort to running my demos externally, instead of dynamically loading them and displaying them in the slides. Most likely this will prevent me from sharing my slides online as well, which is something I have been doing for years.
- Applications that load third party content. Any application that loads plug-ins, modules, or content from third parties is currently very problematic to develop. In order to do so, each piece of content must adhere to a strict coding standard, and expose a common API for deactivating the content. I feel there is also a bit of a security issue here, because the third party content can add a stage listener to prevent itself from being unloaded, then monitor all key and mouse interactions.
- Advertising. It's currently impossible to safely embed AS3 based advertising into an AS3 based site. Most advertising uses timeline code, enterframe listeners, and timers, so if you have rotating banner ads loading into your Flash site, old banners will never stop executing or be removed from memory. Worse yet, if the banners are being served from within your domain, they pose a major security risk, as outlined in #2 above.
Part of what makes this so important is that it entails a reduction of capability from player 8 and AS2. It's also weird messaging for Adobe, that Flash is awesome for building online experiences, and it's great for creating online advertising, but it isn't suitable for developing online experiences with advertising. It will also become increasing important as Flash / Flex sites become more modular, and with increased use of third party content and embedded ads.
Proposal for the Flash Player
At a minimum, I'd like to see the player bug resolved as soon as possible. I also don't think it's unreasonable to hope for some support for content sandboxing and explicit unloading for player 10. The API already has nice hooks for it.
To enable content sandboxing, Adobe could simply extend SecurityDomain to work similarly to ApplicationDomain, allowing developers to put loaded content into a new security domain, so that it cannot access the loading SWF. The nice things about this is that it wouldn't require any new APIs, it would mirror an existing model, and there are already mechanism for dealing with this (this is essentially what happens when you load a SWF from another domain). We also already have a nice model for communicating with sandboxed content with childSandboxBridge and sharedEvents.
For explicit unloads, I would suggest simply adding a Loader.dispose() or Loader.remove() method. This could work just with sandboxed content, and throw an error if the content cannot be removed.
These changes wouldn't directly solve every issue, but they would give developers the tools to address all the major problems themselves.
Work-Arounds and Strategies
There are four main things you can do to address these issues now:
- Make sure that you are always removing timer and enterframe event listeners in content you may want to load into a larger application. Also, try to avoid stage listeners where possible, and remove them immediately when you are done with them.
- Expose a standard API in your SWFs that allows other SWFs to tell it to clean up and stop executing. This way, the loading application can call this method (within a try/catch block) before it unloads any content. I would suggest a .halt() method, backed by a listener for a "halt" event through sharedEvents.
- You can load content SWFs from a subdomain. This will place it into a security sandbox implicitly.
- Load content into a div layered over your main application. This isn't a great option, but it addresses almost all of the issues.
Providing Feedback to the Player Team
If you'd like to provide feedback to the Flash Player team on this or other issues, you can do so at this URL:
http://www.adobe.com/bin/fp8betafeedback.cgi
The player team is a group of smart, dedicated people, who are genuinely interested in what you have to say. They read every submission they get from that form.
If you do contact them about this issue, feel free to point them to this page for the explanation, but also let them know how this issue might impact your work.
Comments (51)
Grant, thanks for bringing important issues like this up for the community. - William
Posted by: William Haun at April 7, 2008 02:08 PMURL: http://www.williamhaun.com/
Always an excellent article Grant. I hope the flash player team could solve this issue for the next version.
Regards.
Posted by: Alberto Gonzalez at April 7, 2008 02:16 PMURL: http://x-geom.net/blog
Very nicely put. We have been fighting these exact issues at my company for a while now. We run games that need to continue to run 24/7 for months. This is quite problematic with Flash's minimal memory management options. Thanks for the article.
Posted by: Nate Chatellier at April 7, 2008 03:13 PMURL: http://blog.natejc.com
Thank you for clear description of what is happening. We've been plagued by Flash's grabby behavior in Flash Player 9 for quite a while. In our loaded mini-games we do what you suggested in #2 above - expose an API that encourages good behavior and cleanup.
Posted by: Jobe Makar at April 7, 2008 03:45 PMURL: http://jobemakar.blogspot.com
Wait, I am confused. I thought you COULD specify a securityDomain when loading a swf. Anything loaded to the null security domain couldn't access your swf code.
Posted by: arpit at April 7, 2008 03:54 PMURL: http://arpitonline.com/blog
Arpit,
Currently, SecurityDomain is only relevant to SWFs loaded cross domain, and they only give you two options:
1) Load the SWF in it's own domain
2) Load the SWF as if it were in your domain
I'm proposing extending the model to allow you to load SWFs from your own domain as though they were in a separate domain. This way you could isolate different SWFs in completely different security domains, or even put multiple SWFs in a shared (but separate) domain.
Cheers.
Posted by: Grant Skinner at April 7, 2008 04:10 PMURL: http://gskinner.com/blog/
Grant,
Well put. I've been voicing my opinion in mass on this subject. It's so bad that for some large scale pieces, I don't recommend clients use AS3 or convert to it. Take a site like Disney.com, with so much 3rd party content loaded in, it's a sitting volcano. Another which has already been noted is a Game loader. The list goes on and on when you are building apps that deal with content you can't completely control. It's pretty scary because most people don't understand the implications of it. I've voiced it before, but you have my support 10 fold on this one.
Posted by: Kenny Bunch at April 7, 2008 04:14 PMURL:
Glad to hear I'm not the only one frustrated by this.
Just to reiterate, if this is causing you problems now, or is likely to cause issues for you in the future, please do use the Flash Player feedback form linked above to tell the player team why this impacts you. They do read that feedback, and it really does have an effect on how they allocate resources for player development.
Posted by: Grant Skinner at April 7, 2008 05:16 PMURL: http://gskinner.com/blog/
We're building a LMS in avm2 trying to leverage the ability to load avm1 and avm2 flash content (especially captivate) and the biggest headache in the development has been the flash content itself (which imo, shouldn't be).
Memory usage goes through the roof pretty fast, and theres no way for me to protect the application from the loaded content, let alone unload a swf with sound that is happy to continue playing long after the user has moved on, and I've unloaded(?) the content.
Posted by: ian at April 7, 2008 06:31 PMI can only hope the player team can dedicate some time to it.
URL:
This problem affects us pretty significantly as well - our core application is a movie editor with hundreds of different swfs representing different fx and transitions, all authored by our artists. These days, we simply don't use the timeline in Blaze when authoring content - we have programmers go through and re-code the content the artists produce, with a manual destroy method where they explicitly free resources. There are some huge memory leaks in basic timeline operations even aside from the unloading issues. Adobe gave us the impression that they know about at least some of the issues but they won't be fixed for Flash 9. In the meantime, our crappy workaround was writing a library that repeatedly attempts to stop the swf and recurses into all children attempting to stop them if they're movieclips, keeping track of currentFrame on all the movieclips encountered during traversal until they've all stopped (why there's no isPlaying method on MovieClip is beyond me). It often takes 2-3 frames to stop the SWF since they might be spawning new children in the process, but this eventually works.
Posted by: Scott Shumaker at April 7, 2008 08:23 PMBefore I wrote the library, they'd continue sucking CPU resources forever.
URL: http://www.flektor.com
Great article, Grant. This is definitely a huge deal that is causing all of us large amounts of frustration.
Posted by: Ryan Taylor at April 7, 2008 11:37 PMURL: http://www.boostworthy.com
Great article Grant. I've recently done a kids CD ROM game based on Flash and ensuring that unloading content did not cause problems took almost 10% of my time on the project. This is stuff that the client don't want to pay for and that you just have to do (or the game will suck). Not very pleased to have to spend that extra time...
I learned quite a bit about unloading and memory during the project (i.e. never have streaming sounds present in frame one of a timeline animation or they will become "ghost sounds"), but I really should not have to. Flash should "just work" without resorting to odd solutions.
J
Posted by: Jensa at April 8, 2008 01:13 AMURL: http://www.flashgamer.com
Great article!
You said: "For explicit unloads, I would suggest simply adding a Loader.dispose() or Loader.remove() method."
This might also be useful for DisplayObject (or even Object).
Without it, programmers have to handle in-game dynamic content by reference counting, etc.. and it's also prone to errors and also adds 10% time managing stuff that was well done in AS2.
For example, in a game a room section edited by a level designer (or an animator) could contain an ENTER_FRAME (that's a pretty common stuff in games ;-)).
Posted by: gludion at April 8, 2008 03:33 AMIn such case, unloading this movieClip is useful, efficient, and doesn't force the designer to learn memory-management stuff unrelated to the (more interesting, to my opinion) subject he's dealing with (a monster, an AI, etc..)
URL: http://blog.gludion.com/2007/08/as3-or-not-as3.html
So that's why! Right, this makes sense now, thanks for clarifying things Grant!
Posted by: Mr.doob at April 8, 2008 03:44 AMURL: http://mrdoob.com
Really thanks for sharing your knowledge, it helps a lot.
Those behaviors make it very easy to leak in our applications. On top of that, the whole framework has a hug memory footprint. Take for instance Buzzword : after a few minutes, it takes more than 100Mo. M$ Word only amounts to 10Mo (and the feature set is quite different...)
So far, that was not too problematic for a web application - a reload and it resets the memory. But for AIR, a desktop technology - thus meant to run much time-lengthier applications, that is a huge problem.
Maybe it's the same for other VM languages such as Java (but at least with Java leaks are much less frequent) but I really doubt we will see big applications moved to AIR...
{Maz}
Posted by: Maz at April 8, 2008 08:01 AMURL: http://labs.businessobjects.com
Thanks for bringing this to light Grant. This is an issue to worry about, and one I hope gets addressed very soon, as it could affect the ability to convince clients to move to AS3. Personally, I'd rather not go back to AS2! I've sent my voice along and hope that others do too.
Posted by: Mike J at April 8, 2008 09:37 AMURL: http://mx.coldstorageonline.com
Great article, I was wondering why the memory usage keeps increasing even if I "remove everything".
Posted by: Luis Neng at April 8, 2008 10:26 AMURL: http://www.spirituc.com
I had this exact problem... I have an experience site that suffers from this issue. I had to re-code loaderManagers 3 times, and then deal with stuff always being in RAM. unload is bogus and setting stuff to null is bogus, removing event listeners is bogus, garbage collection in flash is a skam.
Why can't we excplicitly tell a loaded object to die?!!
Posted by: Patrick at April 8, 2008 12:13 PMURL: http://reduxdj.org
This is a huge issue for our courseware runtime and course editor. Our clients love to use 3rd party animations that they bought or made-captivate for example- and it's going to get harder to support it. Under AS2 i already fight with messy animation files, but this issue has slowed our move to AS3 in the runtime.
Posted by: Ethan at April 8, 2008 01:01 PMURL:
One of our developers said that he noticed the same problem. Try setting the variable that you loaded the swf into to null.
Posted by: Elliot Geno at April 8, 2008 02:04 PMURL: http://www.pyrografix.com
Elliot, while that is good practice, it does not affect any of the issues outlined. Please feel to read through the Background section above, and the linked Resource Management articles for more information on this.
Posted by: Grant Skinner at April 8, 2008 02:12 PMURL: http://gskinner.com/blog/
Thx a lot for the explanation ! Very instructive ! We had a lot of difficulty with with our website http://mtl12.com because of those problems.
Posted by: Fardeen at April 8, 2008 09:22 PMURL: http://fardeen.biz
This is great information. Thanks.
Have you posted this into the Flash Player JIRA yet?
https://bugs.adobe.com/flashplayer/
Posted by: Steve Mathews at April 9, 2008 10:31 AMURL: http://www.flypaper.net
Hello Grant,
Posted by: IlTimido at April 10, 2008 01:09 AMAbout the Flash Player 9 Bug...
You wrote "This also affect timeline code written in Flash authoring - if you have any code in your timeline, it will not be possible to unload that SWF."
I have a newbie question: when you say "timeline code", do you mean also a simple "stop()" or not? (in fact also a "stop" is a line of code)
I ask because I normally load external assets that do not contains code but only a few "stop()" and I was thinking that these assets were disposed when I remove them from the display list and set any pointer to them to null.
Thanks in advance (and sorry for my english).
URL: http://www.genereavventura.com
Thanks for these useful informations! Are there any chance for a coming official whitepaper about these optimalization techniques and best practices?
Posted by: Andras at April 11, 2008 04:00 AMMost of the flash developers are affected about these things I think.
URL: http://www.vpmedia.hu
There are a couple of memory releasing tips in this Ultrashock thread...
http://www.ultrashock.com/forums/random-chat/failure-to-unload-flash-player-9s-dirty-secret-99237.html
Getting a Loader to actually unload is easy enough to do but requires the LocalConnection GC hack.
Posted by: Si ++ at April 11, 2008 06:27 AMURL:
Si++,
Sorry, but the information in that thread is incorrect, and even harmful.
First, it is bad practice to use the LocalConnection hack in a real project (as mentioned in my original article on tools for resource management in AS3, which is most likely where Nutrox learned of it). I have to admit I debated sharing that technique, because I knew some people would misuse it, but it's also hugely useful for testing GC issues.
For your reference, here is the article:
http://www.gskinner.com/blog/archives/2006/08/as3_resource_ma_2.html
Secondly, even if it was an ok practice, all the hack does is run the garbage collector, which suffers from the bug mentioned in this article, regardless of how you initiate it.
It's worth noting that all of the testing for this article was done using the LC hack, so I know for sure that it does not resolve any the issues.
I wish there were easy answers to this one, but there isn't.
Posted by: Grant Skinner at April 11, 2008 08:15 AMURL: http://gskinner.com/blog/
On the other hand, Nutrox's ByteArray trick does work, and is quite interesting. Worth checking out. I might add that to the resource management tools article.
myByteArray.length = 0;
Posted by: Grant Skinner at April 11, 2008 08:32 AMmyByteArray = new ByteArray();
// causes an immediate collection of the old byte array data.
URL: http://gskinner.com/blog/
Great great info Grant, thanks much. Would you elaborate on the extent to which workaround #3 does (and doesn't) solve the problems? That's the approach we're planning to take.
Posted by: Darrin Massena at April 11, 2008 09:53 AMURL: http://www.picnik.com
Yar, I understand that the LC hack isn't the best thing to use, but until Adobe sort out the problem it looks as though it is our only choice at the moment. I think the code posted in the Ultrashock thread is heading in the right direction, timeline code seems to be unloading correctly now (I double-checked that numerous times), and loading some temp content into the loader also seems to be helping.
We'll have to see how things pan out though. If you're coding your own stuff and know about this issue then it does seem to be avoidable/fixable/hackable, but there are no doubt going to be serious problems with those programmers who aren't knowledgeable about this kind of stuff.
Posted by: Si ++ at April 11, 2008 09:54 AMURL:
It would be nice (even if this is fixed in the future without having us to care about it) something along the lines of "UnloadingMainDocumentEvent", so we could manage in a better way the release of objects or make some sort of checking for saving shared objects or whatever.
Posted by: Hector at April 11, 2008 01:56 PMURL:
Hey Grant --
Great articles. I have an AS3 project that loads external swf files with timeline code limited to simple stop() and eventlisteners. All swfs have a stop(); action on the first frame, with everything else on succeeding frames. I notice a constant memory usage increase UNTIL the loaded swfs have all played to the end of their timeline and all code has executed. Then memory usage stabilizes. I don't need or want to unload the assets, but would like to make sure the memory leak doesn't happen. I guess I need to get my designers to put all their code on frame 1...
jk
Posted by: Jay Kerr at April 11, 2008 03:06 PMURL:
Does any of this apply when loading an AVM1 movie into an AVM2 document?
For example, i load an AVM1 movie. Am I wrong feel that i can safely avoid a lot of these problems if I just limit the externally loaded swfs (say headers) to being simple AVM1 movies, which i then unload?
Posted by: mario gonzalez at April 11, 2008 06:09 PMURL: http://onedayitwillmake.com
Thanks Grant , I came across this post which links to an adobe public bug report/reference system : http://justin.everett-church.com/index.php/2008/04/08/flash-player-needs-your-vote
I have just clicked through , will have a look if this bug you have mentioned is listed there ..?
I am pro the "Loader.dispose() or Loader.remove() " idea ..
Posted by: ian at April 12, 2008 03:28 AMURL: http://www.entertainmentafrica.com
Wow, looks like there's a lot of loading going on in the Flash community.
I'm working on a game on AIR that loads minigames from "module" swf files, and I've been considering the submission process for module developers. Until a system like the one that you describe limits modules' access to things like the stage, the best option I can think of is to "proofread" each submission's source code and compile it myself.
Fortunately, in my case the loaded are in a different security sandbox than my loader, and I can use sandbox bridges to tighten security around my modules. But I doubt that I can protect the stage.
Posted by: Rezmason at April 13, 2008 11:54 AMURL: http://www.rezmason.net
the lastest version of Flash Player 9.0.124.0 was released, but this bug is still there, seems Adobe does not want to fix it.
Posted by: Jerry.Wang at April 13, 2008 11:39 PMURL:
Dear Grant,
Thanks for this informative article
Is this issue carried to AIR as well? Do we have to quit and re-start the air app every time when it becomes slow because of loaded contents (which could not be unloaded)
Regards,
Posted by: Arul at April 14, 2008 09:41 PMArul
URL: http://www.shockwave-india.com/blog
Grant, please log a bug with the Adobe Bugbase ( http://bugs.adobe.com/jira/browse/FP ). I think I speak for many that you are the most authoritative to issue such a detailed bug report, and the sooner it gets logged, the sooner people can vote on it, and the sooner it can be taken seriously. Adobe will pay more attention to its bugbase than a wishlist. Let's get a bug report petition started!!
Posted by: Joeflash at April 15, 2008 11:09 AMURL: http://blog.joeflash.ca
YEAH, log a bug.
Posted by: Tim K at April 17, 2008 06:10 AMURL: http://timkindberg.com
Hopefully Adobe will fix this problem really soon! I just finished a big project and we tried a thousand solution but none of them worked.
The best thing to do is keep track of your memory usage from the start of the project. I made a Profiler which is a part of my framework and can be downloaded from http://code.google.com/p/braemar/source/browse/trunk/nl/flashaddict/braemar/utils/Profiler.as
Hope this helps.
Posted by: Patrick Pietens at April 17, 2008 01:43 PMURL: http://www.flashaddict.nl
Hi,
A very thorough and informative article. I am left somewhat saddened that such bug, which must rate as high (if not critical), could persist in the player for so long.
Posted by: Flexy at April 18, 2008 10:00 AMURL: http://www.flexdeveloper.eu
Has anyone had any success using the new System.gc() method available as of FP9 Update 3?
Theoretically it's supposed to force start the garbage collection, but at least in the standalone player, I haven't noticed any effect.
Posted by: Patrick Polujan at April 18, 2008 01:04 PMURL:
Patrick: See this very important article
http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/
Basically you need to call it twice.
Posted by: Danny Miller at April 18, 2008 10:28 PMURL: http://www.k2xl.com
A presentation about memory management, maybe it's interesting for others:
Posted by: Andras at April 21, 2008 11:00 AMhttp://labs.realeyes.com/downloads/Memory%20Management%20for%20Flex%20Developers.pdf
URL: http://www.vpmedia.hu
Thanks Grant.. It helped me in clearing up certain things that intrigued me in my last job, where i was involved in building UIs for various products..
Posted by: Hafiz at April 23, 2008 04:00 AMURL: http://www.blog.uiandtheworld.com
Hi Grant,
Thanks a lot of these article as we knew we were sitting on a mine field but didnt really know how to tackle stuff. Some of our problems are now solved, thanks to your articles.
As soon as the loaded swf is unloaded, we can see this in the debugger output window:
[UnloadSWF] assets/somefile.swf
However, for the files which have Flash components, we never see anything like this and I assume it remains in the memory. Do you know any solution to this?
Posted by: AJ at April 23, 2008 06:09 AMURL: http://www.arpit.net/blog
Yes we had this problem in our current project... only for it to rear its ugly head at the end of 2 months ... dang
Posted by: Jarrad Hope at May 5, 2008 03:00 AMURL:
Garbage collection, works great for Java, but Java only has 1 java program and never the case of a java program loading another external java program. Did Adobe forgot that Flash is different from Java in that repsect, with external SWFs running their own code as well? If the SWF is unloaded before actual de-allocation occurs, would GC run for an unloaded SWF's resources? Definitely not.
The safest way,it seems, is that all interactivity has to be coded from a cental mainframe or API that is always running to ensure such resources can always be allocated/deallocated safely by GC. Do it in perishable SWFs, well, knowing how GC works, it isn't surprising...That's just the way FP9 works.
Flash galleries can still be done with a LightBox (div layered) js webpage i guess.
As for enterframe loops, I normallly do a single engine loop from a single mainframe, so i never encountered this issue, since the main engine loop executes the loaded content, and all loaded content are raw and subjected to the parent from a top-down approach. The child "pages" never runs its own code.
Works for applications and fixed-format websites. But for sites loading 3rd party content or external swfs with their own unique internal code....a NIGHTMARE.
Posted by: Glenn at May 8, 2008 08:42 AMURL:
I have the same question as IlTimido which is giving me much trouble so I'll repost the question:
Posted by: Matt at May 8, 2008 06:21 PMGrant, You wrote: if you have any code in your timeline, it will not be possible to unload that SWF." When you say "timeline code", do you mean also a simple "stop()" or not? or a simple gotoAndPlay() as a loop on the timeline. Is it impossible to unload these swf's ?
URL:
Matt & IlTimido,
I haven't invested a huge amount of time testing this, but it appears to only affect code on running or looping timelines. So once your timeline stops, it should be GCed, but as long as a timeline with code is playing, the SWF will not be collected.
Posted by: Grant Skinner at May 8, 2008 10:11 PMURL: http://gskinner.com/blog/
Say, Grant, I think I've come up with a terribly inefficient solution to the problem of keeping loaded SWF content from accessing the main application's Stage instance: BitmapData! Just leave your Loader instance off the display list, but draw it repeatedly to a bitmap object that is!
This cannot be optimized by computing and using the redraw region to clip the area being drawn. But it is a way of displaying loaded data safely, and could be extended to create mouse events dispatched from the loaded objects themselves.
Posted by: Rezmason at May 9, 2008 09:33 PMURL: http://www.rezmason.net/