Added setShutdownOnRemove(), which is disabled by default, but will

automatically shutdown (stop the loading and unload()) when removed from the stage.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@479 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2008-04-30 21:11:39 +00:00
parent ad347a4c8d
commit ef6a5e208c
@@ -179,6 +179,16 @@ public class MediaContainer extends Sprite
didShowNewMedia();
}
/**
* Sets whether this MediaContainer automatically shuts down when removed
* from the stage. By default this is not enabled.
*/
public function setShutdownOnRemove (enable :Boolean = true) :void
{
var fn :Function = enable ? addEventListener : removeEventListener;
fn(Event.REMOVED_FROM_STAGE, handleShutdownOnRemove);
}
/**
* A place where subclasses can initialize things prior to showing new media.
*/
@@ -590,6 +600,15 @@ public class MediaContainer extends Sprite
stoppedLoading();
}
/**
* Handle shutting us down when we're removed. Only called if
* setShutdownOnRemove() was enabled.
*/
protected function handleShutdownOnRemove (event :Event) :void
{
shutdown();
}
/**
* Configure the mask for this object.
*/