日期:2014-05-16 浏览次数:20483 次
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="400" height="350" initialize="TestLoadBytes()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var loader:Loader;
private var urlLoader:URLLoader;
private var container:Sprite;
private var urlstr:String = "http://acserver/SWFINHTML/a.swf";
private function TestLoadBytes():void
{
urlLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, urlLoaderCompleteHandler);
urlLoader.load(new URLRequest(urlstr));
}
private function urlLoaderCompleteHandler(event:Event):void
{
var lc:LoaderContext = new LoaderContext();
lc.allowLoadBytesCodeExecution = true;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler)
loader.loadBytes(urlLoader.data, lc);
}
private function loadCompleteHandler(event:Event):void
{
container = new Sprite();
container.addChild(loader.content);
ui.addChild(container);
}
]]>
</mx:Script>
<mx:VBox id="vbox" width="100%" height="100%" top="30" left="30">
<mx:UIComponent id="ui" width="100%" height="100%"/>
</mx:VBox>
</mx:WindowedApplication>
配置文件用flex builder自动生成的就行了。
a.swf
结果: