Some rearrangements to improve subclassability.

I had a subclass loading the new zip files that will be remixable avatars,
but that's going to have to be restructured (complexity++) for security
reasons.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@393 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2008-01-11 00:06:09 +00:00
parent 56df6f1913
commit 3645d831a7
+30 -15
View File
@@ -140,12 +140,7 @@ public class MediaContainer extends Sprite
// set up the new media // set up the new media
willShowNewMedia(); willShowNewMedia();
if (StringUtil.endsWith(url.toLowerCase(), ".flv")) { showNewMedia(url);
setupVideo(url);
} else {
setupSwfOrImage(url);
}
didShowNewMedia(); didShowNewMedia();
} }
@@ -183,6 +178,16 @@ public class MediaContainer extends Sprite
_isImage = false; _isImage = false;
} }
protected function showNewMedia (url :String) :void
{
if (StringUtil.endsWith(url.toLowerCase(), ".flv")) {
setupVideo(url);
} else {
setupSwfOrImage(url);
}
}
/** /**
* A place where subclasses can configure things after we've setup new media. * A place where subclasses can configure things after we've setup new media.
*/ */
@@ -211,6 +216,24 @@ public class MediaContainer extends Sprite
{ {
startedLoading(); startedLoading();
var loader :Loader = initLoader();
loader.load(new URLRequest(url), getContext(url));
try {
var info :LoaderInfo = loader.contentLoaderInfo;
updateContentDimensions(info.width, info.height);
} catch (err :Error) {
// an error is thrown trying to access these props before they're
// ready
}
}
/**
* Initialize a Loader as our _media, and configure it however needed to prepare
* loading user content.
*/
protected function initLoader () :Loader
{
// create our loader and set up some event listeners // create our loader and set up some event listeners
var loader :Loader = new Loader(); var loader :Loader = new Loader();
_media = loader; _media = loader;
@@ -219,17 +242,9 @@ public class MediaContainer extends Sprite
info.addEventListener(Event.INIT, handleInit); info.addEventListener(Event.INIT, handleInit);
info.addEventListener(IOErrorEvent.IO_ERROR, loadError); info.addEventListener(IOErrorEvent.IO_ERROR, loadError);
info.addEventListener(ProgressEvent.PROGRESS, loadProgress); info.addEventListener(ProgressEvent.PROGRESS, loadProgress);
// start it loading, add it as a child
loader.load(new URLRequest(url), getContext(url));
addChildAt(loader, 0); addChildAt(loader, 0);
try { return loader;
updateContentDimensions(info.width, info.height);
} catch (err :Error) {
// an error is thrown trying to access these props before they're
// ready
}
} }
/** /**