0

我正在尝试使用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()

主意?请帮忙!

谢谢指教!

4

1 回答 1

0

知道了!

我更改了 JW Player 源类中的一些函数。

com/longtailvideo/jwplayer/media/YouTubeMediaProvider.as的函数initializeMediaProvider( ) 中添加Security.allowDomain("*");

com/longtailvideo/jwplayer/model/Model.as函数setupMediaProviders()中注释了以下行:setMediaProvider('default', new MediaProvider('default')); setMediaProvider('youtube', new YouTubeMediaProvider());

我没有使用 youtube,所以它工作正常!

希望这可以帮助!

于 2011-03-17T09:34:59.473 回答