From ec93c75cc26893bee99988147a50e6ec934b677b Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 25 Jun 2008 22:55:16 +0000 Subject: [PATCH] Added setMediaBytes(). git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@553 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/MediaContainer.as | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/as/com/threerings/flash/MediaContainer.as b/src/as/com/threerings/flash/MediaContainer.as index 20da7d91..0889e4e6 100644 --- a/src/as/com/threerings/flash/MediaContainer.as +++ b/src/as/com/threerings/flash/MediaContainer.as @@ -45,6 +45,8 @@ import flash.events.TextEvent; import flash.geom.Point; import flash.geom.Rectangle; +import flash.net.URLRequest; + import flash.text.TextField; import flash.text.TextFieldAutoSize; @@ -53,7 +55,7 @@ import flash.system.LoaderContext; import flash.system.Security; import flash.system.SecurityDomain; -import flash.net.URLRequest; +import flash.utils.ByteArray; import com.threerings.util.Log; import com.threerings.util.StringUtil; @@ -154,6 +156,22 @@ public class MediaContainer extends Sprite } } + /** + * Set the media to display as a ByteArray. + */ + public function setMediaBytes (bytes :ByteArray) :void + { + if (_media != null) { + shutdown(false); + } + _url = null; + + willShowNewMedia(); + startedLoading(); + initLoader().loadBytes(bytes, getContext(null)); + didShowNewMedia(); + } + /** * Configure our media as an instance of the specified class. */ @@ -492,6 +510,10 @@ public class MediaContainer extends Sprite */ protected function isImage (url :String) :Boolean { + if (url == null) { + return false; + } + // look at the last 4 characters in the lowercased url switch (url.toLowerCase().slice(-4)) { case ".png":