Handle showing a resource class or an already-configured DisplayObject.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4433 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -65,6 +65,15 @@ public class MediaContainer extends Box
|
||||
horizontalScrollPolicy = ScrollPolicy.OFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the media. If the media was loaded using a URL, this will
|
||||
* likely be the Loader object holding the real media.
|
||||
*/
|
||||
public function getMedia () :DisplayObject
|
||||
{
|
||||
return _media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the media to display.
|
||||
*/
|
||||
@@ -84,6 +93,32 @@ public class MediaContainer extends Box
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure our media as an instance of the specified class.
|
||||
*/
|
||||
public function setMediaClass (clazz :Class) :void
|
||||
{
|
||||
setMediaObject(new clazz() as DisplayObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure an already-instantiated DisplayObject as our media.
|
||||
*/
|
||||
public function setMediaObject (disp :DisplayObject) :void
|
||||
{
|
||||
if (_media != null) {
|
||||
shutdown(false);
|
||||
}
|
||||
|
||||
if (disp is UIComponent) {
|
||||
addChild(disp);
|
||||
} else {
|
||||
rawChildren.addChild(disp);
|
||||
}
|
||||
_media = disp;
|
||||
updateContentDimensions(disp.width, disp.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure this sprite to show a video.
|
||||
*/
|
||||
@@ -284,33 +319,10 @@ public class MediaContainer extends Box
|
||||
*/
|
||||
protected function getContext (url :String) :LoaderContext
|
||||
{
|
||||
/* Super unrestrictive */
|
||||
// return null;
|
||||
|
||||
/* a little unrestrictive */
|
||||
// return new LoaderContext(false,
|
||||
// ApplicationDomain.currentDomain,
|
||||
// null);
|
||||
|
||||
/* more restrictive */
|
||||
// We allow content to share but not overwrite our classes
|
||||
return new LoaderContext(false,
|
||||
new ApplicationDomain(ApplicationDomain.currentDomain),
|
||||
null);
|
||||
|
||||
/*
|
||||
var loadCtx :LoaderContext = (_loadCtx.get(url) as LoaderContext);
|
||||
if (loadCtx == null) {
|
||||
trace("Creating new loadctx for " + url);
|
||||
loadCtx = new LoaderContext(
|
||||
false,
|
||||
//new ApplicationDomain(ApplicationDomain.currentDomain),
|
||||
ApplicationDomain.currentDomain,
|
||||
null
|
||||
);
|
||||
_loadCtx.put(url, loadCtx);
|
||||
}
|
||||
return loadCtx;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,6 +402,11 @@ public class MediaContainer extends Box
|
||||
var info :LoaderInfo = (event.target as LoaderInfo);
|
||||
removeListeners(info);
|
||||
|
||||
// trace("Loading complete: " + info.url +
|
||||
// ", childAllowsParent=" + info.childAllowsParent +
|
||||
// ", parentAllowsChild=" + info.parentAllowsChild +
|
||||
// ", sameDomain=" + info.sameDomain);
|
||||
|
||||
updateContentDimensions(info.width, info.height);
|
||||
updateLoadingProgress(1, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user