1

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?

SimonRH
  • 1,409
  • 2
  • 13
  • 23
  • I've discovered that the error only appears on Windows. No error on a Mac. I'm wondering if this is an issue with my version of Flash Player. On Windows I am running: 16.0.0.235 (debugger version). The latest version is 16.0.0.237, but that does not appear to have a debugger version available.version available. – SimonRH Jan 22 '15 at 19:01
  • possible duplicate of [Security Sandbox Violation Flash AS3](http://stackoverflow.com/questions/15801009/security-sandbox-violation-flash-as3) – ketan Jan 23 '15 at 04:00

1 Answers1

2
  • You got ( saw ) the #2121 security error because you are using a Flash Player debug version but when using a "normal" version you will get nothing ( as you said although ) and your player will load the youtube content as any other player without problems. The debug version of Flash Player is intended for developers for debug and test purposes, so don't care about these security alert if your content is loaded normally with the "normal" version which is used by all non-developer users.

  • The security error is fired when youtube.com try to access to the watch_as3.swf file from s.ytimg.com, so here you can do nothing to avoid that error because the Security.allowDomain should be used in that swf file which is maintained by google to my knowledge ;)

  • The Security.allowDomain function is used like this:

    // we use only the domain name not all the file url
    Security.allowDomain('example.com');       // or http://example.com

    // or the ip address 
    Security.allowDomain('10.10.10.10');       // or http://10.10.10.10

    // or a wildcard "*" to allow all domains
    Security.allowDomain('*');

Hope that can help.

akmozo
  • 9,829
  • 3
  • 28
  • 44