Hmm, Loader.unload() only removes the content from the loader object. It
might be a good idea to remove it from the container you are adding it to.

Make sure currentPage has no listeners to objects outside of its own scope,
or objects inside of its scope listening to anything out of its scope, or
objects outside of its scope referencing anything inside of its scope, and
all streams closed when you unload. Always clean up timers and enterframe
listeners from the swf being loaded. It is a good idea to have a deinit()
like method that you call for clean up. I think you're okay if you're
cleanly in general :)

Here is a nice article about System.gc(), it might be helpful:
http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/

And if you haven't already, check this out:
http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html

H

On Fri, Aug 15, 2008 at 7:41 AM, Sander Schuurman <
[EMAIL PROTECTED]> wrote:

> Hi cool list!
>
> I'm trying do build a generic structure of pages (swf's) loaded in a main
> swf, and unloading as well ofcourse.
> Now I'm trying to unload a loaded swf, with the famous Garbage Collection.
> But I'm not sure I'm doing it the right way. Hope you could point me in the
> right direction.
>
> My code:
>
> private function loadPage( qUrl :String ) :void
> {
>            var mLoader:Loader                    = new Loader();
>            var mRequest:URLRequest         = new URLRequest( qUrl );
>
>            mLoader.contentLoaderInfo.addEventListener( Event.COMPLETE,
> pageComplete );
>            mLoader.load( mRequest );
> }
> private function pageComplete( e :Event ) :void
> {
>            currentPage = e.currentTarget.content;
>
> currentPage.addEventListener( Page.PAGE_INIT, initPage );
>            currentPage.addEventListener( Page.GOTO_PAGE, gotoPage );
>
>            addChild(currentPage);
> }
> private function gotoPage( e :Event ) :void
> {
>            var nextPage = currentPage.gotoPage;
>
>            currentPage.removeEventListener( Page.PAGE_INIT, initPage );
>            currentPage.removeEventListener( Page.GOTO_PAGE, gotoPage );
>
>            var loader:Loader = Loader( e.target );
>            loader.unload();
>
>            loadPage( nextPage );
> }
>
> I'm not sure about the gotoPage method, if I can make a Loader object of
> the currentPage and unload it. Is it totally ready for the GC to be deleted?
> Thnx in advance.
>
> Sander
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to