as3 将上传的 swf 嵌入到场景中

as3 embed uploaded swf into scene

 var file:FileReference=new FileReference();

然后

trace (file.data);

工作正常

之后,我尝试将接收到的数据嵌入到场景中,但没有成功

var ExtSWF:MovieClip;
ExtSWF = file.data.readObject() as MovieClip;
trace(ExtSWF);

returns 空

但如果我将它作为远程文件加载,Loader - 它工作正常

var ldr:Loader = new Loader();
ldr.load(new URLRequest("ext.swf"));
......
ExtSWF = MovieClip(ldr.contentLoaderInfo.content);

是否可以只上传 swf 文件并将其嵌入到场景中,或者 Loader class 是实现此目标的唯一可能性吗?

The Loader class is used to load SWF files or image (JPG, PNG, or GIF) files.

但 "load" 真正意味着“解码格式”用于显示。因此,使用 Loader.loadbytes 通过 Loader 传递 file.data 字节以解码为有效的 MovieClip 对象。

尝试

//var ExtSWF : MovieClip = new MovieClip;
//ExtSWF = file.data.readObject() as MovieClip;
var ldr : Loader = new Loader(); //# declare outside of any functions (make as public var)
ldr.loadBytes(file.data); //#use Loader to auto-decode bytes of SWF
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, on_swfLoaded );

还有解码完成的处理函数...

function on_swfLoaded (evt:Event) : void
{
    var ExtSWF : MovieClip = new MovieClip;
    ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, on_swfLoaded );
    ExtSWF = ldr.content as MovieClip;

    trace(ExtSWF);
    ExtSWF.x =50; ExtSWF.y = 50; addChild(ExtSWF);
}