I'm trying to play a Youtube video in Flash Builder. Each time I play the file I get an error message:
SecurityError: Error #2121: Security sandbox violation: Loader.content: https://www.youtube.com/v/FGtTEmBR7Sk cannot access https://s.ytimg.com/yts/swfbin/player-vflQiDuyQ/watch_as3.swf. This may be worked around by calling Security.allowDomain.
at flash.display::Loader/get content()
at com.google.youtube.application::SwfProxy/onRequestParameters()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.google.youtube.model::YouTubeEnvironment()
at com.google.youtube.application::WatchPageVideoApplication/createYouTubeEnvironment()
at com.google.youtube.application::VideoApplication/onLoaderInfoInit()
I have tried to use the recommended work around (see below) but nothing I do will stop the error message. I've also downloaded and tried out several sample files from the web, but each time I get an error message.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" creationComplete="init()">
<mx:Script>
<![CDATA[
[Bindable] private var videoUrl:String;
private function videoToPlay():void{
Security.allowDomain("http://www.youtube.com/v/FGtTEmBR7Sk");
Security.allowDomain("https://s.ytimg.com");
Security.allowDomain("https://s.ytimg.com/yts/swfbin/player-vflQiDuyQ/watch_as3.swf");
Security.allowDomain("*");
videoUrl = "http://www.youtube.com/v/FGtTEmBR7Sk";
}
]]>
</mx:Script>
<mx:Button label="Play" click="videoToPlay()" useHandCursor="true" buttonMode="true" />
<mx:Canvas>
<mx:SWFLoader id="swfLoader" source="{videoUrl}" width="640" height="387" />
</mx:Canvas>
</mx:Application>
Can anyone tell me what is wrong with my code or point me to a working example that shows how to embed a youtube file in Flash Builder?