Broke unloading the media out into its own method.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@696 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2008-11-12 02:48:19 +00:00
parent d7e607972d
commit e4dd02746c
+32 -26
View File
@@ -315,7 +315,6 @@ public class MediaContainer extends Sprite
*/ */
public function shutdown (completely :Boolean = true) :void public function shutdown (completely :Boolean = true) :void
{ {
try {
// remove the mask (but only if we added it) // remove the mask (but only if we added it)
if (_media != null && _media.mask != null) { if (_media != null && _media.mask != null) {
try { try {
@@ -331,32 +330,10 @@ public class MediaContainer extends Sprite
} }
} }
if (_media is Loader) { shutdownMedia();
var loader :Loader = (_media as Loader); if (_media != null) {
//var url :String = loader.contentLoaderInfo.url;
// remove any listeners
removeListeners(loader.contentLoaderInfo);
// dispose of media
LoaderUtil.unload(loader);
dispatchEvent(new Event(Event.UNLOAD));
removeChild(loader);
//var extra :String = (url == _url) ? "" : (", _url=" + _url);
//log.debug("Unloaded media [url=" + url + extra + "].");
} else if (_media is SimpleVideoDisplay) {
var vid :SimpleVideoDisplay = SimpleVideoDisplay(_media);
// vid.removeEventListener(VideoPlayerCodes.SIZE, handleVideoSizeKnown);
vid.unload();
removeChild(vid);
} else if (_media != null) {
removeChild(_media); removeChild(_media);
} dispatchEvent(new Event(Event.UNLOAD));
} catch (ioe :IOError) {
log.warning("Error shutting down media", ioe);
} }
// clean everything up // clean everything up
@@ -743,6 +720,35 @@ public class MediaContainer extends Sprite
// nada // nada
} }
/**
* Do whatever is necessary to shut down the media.
*/
protected function shutdownMedia () :void
{
if (_media is Loader) {
try {
var loader :Loader = (_media as Loader);
//var url :String = loader.contentLoaderInfo.url;
// remove any listeners
removeListeners(loader.contentLoaderInfo);
// dispose of media
LoaderUtil.unload(loader);
//var extra :String = (url == _url) ? "" : (", _url=" + _url);
//log.debug("Unloaded media [url=" + url + extra + "].");
} catch (ioe :IOError) {
log.warning("Error shutting down media", ioe);
}
} else if (_media is SimpleVideoDisplay) {
var vid :SimpleVideoDisplay = SimpleVideoDisplay(_media);
// vid.removeEventListener(VideoPlayerCodes.SIZE, handleVideoSizeKnown);
vid.unload();
}
}
/** The unaltered URL of the content we're displaying. */ /** The unaltered URL of the content we're displaying. */
protected var _url :String; protected var _url :String;