0
我試圖使用YouTube AS3 API來顯示一些YouTube視頻到我的flash動畫,但是當我把它上傳到我自己的服務器,瀏覽器顯示此消息:的Youtube API AS3跨域
錯誤#2044:SecurityErrorEvent:文字=錯誤#2121:沙箱安全 違反:HTTP:// * /magicbook.swf?user=25 & ID = 2283: http://www.youtube.com/apiplayer?version=3無法訪問。
我已經添加了我的Security.allowDomain
策略以允許在兩臺服務器之間進行訪問。我究竟做錯了什麼?
這裏是我的代碼:
class YoutubePlayer extends Sprite {
private var player:Object;
private var loader:Loader;
private var _videoID:String;
public function YoutubePlayer(videoID:String) {
Security.allowInsecureDomain("*");
Security.allowDomain("*");
//loader = addChild(new Loader()) as Loader;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit, false, 0, true);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
_videoID = videoID;
}
private function onLoaderInit(event:Event):void {
player = loader.content;
player.addEventListener("onReady", onPlayerReady);
}
private function onPlayerReady(event:Event):void {
player.setSize(320, 180);
player.cueVideoByUrl("http://www.youtube.com/v/"+_videoID,0);
player.addEventListener("onError",seeError);
this.addChild(loader);
}
private function seeError(event:Event):void{
trace("error");
}
public function playYoutube():void{
player.playVideo();
}
public function stopYoutube():void{
player.stopVideo();
}
}
我試過你說的,但它仍然顯示我的錯誤。 –