我正在尝试使用loadBytes将外部 SWF ( JW Player ) 加载到我的 AIR 应用程序中。我正在使用以下代码:
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.ByteArray;
public function Invoker()
{
trace("INIT");
var uldr : URLLoader = new URLLoader();
uldr.dataFormat = URLLoaderDataFormat.BINARY;
uldr.addEventListener(Event.COMPLETE, onBytesComplete);
uldr.load(new URLRequest("Resources/5.1.swf"));
}
private function onBytesComplete(e : Event) : void
{
trace("LOADED");
var bytes : ByteArray = (e.target as URLLoader).data;
var ldr : Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete);
var ldrC : LoaderContext = new LoaderContext();
ldrC.allowLoadBytesCodeExecution = true;
ldr.loadBytes(bytes, ldrC);
}
private function onChildComplete(e : Event):void
{
trace("COMPLETE");
var c1ad : ApplicationDomain = (e.target as LoaderInfo).applicationDomain;
var inad : ApplicationDomain = ApplicationDomain.currentDomain;
trace(c1ad);
trace(inad);
}
但是,当我把
uic.addChild(ldr); 或 canv.addChild(ldr); (uic 是mx:UIComponent和 canv 是mx:Canvas)进入onBytesComplete函数,我得到以下错误:
SecurityError: Error #3207: Application-sandbox content cannot access this feature.
at flash.system::Security$/allowDomain()
at com.longtailvideo.jwplayer.media::YouTubeMediaProvider/initializeMediaProvider()
at com.longtailvideo.jwplayer.model::Model/setMediaProvider()
at com.longtailvideo.jwplayer.model::Model/setupMediaProviders()
at com.longtailvideo.jwplayer.controller::PlayerSetup/setupMediaProviders()
at com.longtailvideo.jwplayer.controller::TaskQueue/nextTask()
at com.longtailvideo.jwplayer.controller::TaskQueue/success()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.longtailvideo.jwplayer.view.skins::DefaultSkin/loadComplete()
主意?请帮忙!
谢谢指教!