From 1df26e881303aa596697eebdf11f53f0039daa20 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 16 Oct 2008 00:49:34 +0000 Subject: [PATCH] Added LoaderUtil, which has unload. Hmm, I'm not able to use unloadAndStop() yet. Perhaps I need to grab an even newer version of the flex SDK, so it's commented out for now. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@669 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/LoaderUtil.as | 35 +++++++++++++++++++ src/as/com/threerings/flash/MediaContainer.as | 11 +----- 2 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 src/as/com/threerings/flash/LoaderUtil.as diff --git a/src/as/com/threerings/flash/LoaderUtil.as b/src/as/com/threerings/flash/LoaderUtil.as new file mode 100644 index 00000000..d31838ed --- /dev/null +++ b/src/as/com/threerings/flash/LoaderUtil.as @@ -0,0 +1,35 @@ +// +// $Id$ + +package com.threerings.flash { + +import flash.display.Loader; + +/** + * Contains a utility method for safely unloading a Loader. + */ +public class LoaderUtil +{ + /** + * Safely unload the specified loader. + */ + public static function unload (loader :Loader) :void + { + try { + loader.close(); + } catch (e1 :Error) { + // ignore + } +// try { +// loader.unloadAndStop(); +// } catch (e2 :Error) { + // hmm, maybe they are using FP9 still + try { + loader.unload(); + } catch (e3 :Error) { + // ignore + } +// } + } +} +} diff --git a/src/as/com/threerings/flash/MediaContainer.as b/src/as/com/threerings/flash/MediaContainer.as index a49db0f3..350a99f2 100644 --- a/src/as/com/threerings/flash/MediaContainer.as +++ b/src/as/com/threerings/flash/MediaContainer.as @@ -328,16 +328,7 @@ public class MediaContainer extends Sprite removeListeners(loader.contentLoaderInfo); // dispose of media - try { - loader.close(); - } catch (ioe :IOError) { - // ignore - } - try { - loader.unload(); - } catch (e :Error) { - // ignore - } + LoaderUtil.unload(loader); dispatchEvent(new Event(Event.UNLOAD)); removeChild(loader);