Skip to main content
Participant
January 4, 2011
Answered

sandbox violation using AS3... PLEASE HELP!!!

  • January 4, 2011
  • 1 reply
  • 3535 views

i'm trying to embed a youtube video in my flash project using AS3.

it works, but i get an ugly error popup when it loads the video thumbnail.

if anyone can help me, i'll be eternally indebted! i've racked my brain and spent 4 hours on google trying to find a solution.

the error message is:

SecurityError: Error #2047: Security sandbox violation: parent: http://www.timesdaily.com/assets/multimedia/flash/10MTW/10MTW.swf cannot access http://s.ytimg.com/yt/swfbin/apiplayer3-vflgvMWON.swf.
    at flash.display::DisplayObject/get parent()
    at fl.managers::FocusManager/isTabVisible()
    at fl.managers::FocusManager/tabEnabledChangeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.google.youtube.ui::UIElement/onAddedToStage()
    at flash.display::DisplayObjectContainer/addChildAt()
    at com.google.youtube.util::Layout/add()
    at com.google.youtube.application::VideoApplication/setPlayButtonVisibility()
    at com.google.youtube.application::VideoApplication/onAppStateChange()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.google.youtube.application::VideoApplication/setAppState()
    at com.google.youtube.application::VideoApplication/cueVideoById()
    at 10MTW_fla::MainTimeline/onPlayerReady()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.google.youtube.application::SwfProxy/onExternalEvent()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.google.youtube.model::YouTubeEnvironment/broadcastExternal()
    at com.google.youtube.application::VideoApplication/onInited()
    at com.google.youtube.application::Application/initData()
    at com.google.youtube.application::VideoApplication/initData()
    at com.google.youtube.application::Application/init()
    at com.google.youtube.application::VideoApplication/init()
    at com.google.youtube.application::Application/onInit()

and my AS3 code:

this.stop();

mainmenusmall.addEventListener(MouseEvent.CLICK,mainmenubutton5);

function mainmenubutton5(evtObj:MouseEvent) {

    //trace action shows what's happening in output menu

    trace("The main menu button was clicked!");

    //go to section command

my_player.stopVideo()

removeChild(my_loader)

gotoAndPlay(1);

}

Security.allowDomain("*");

var my_player:Object;

var my_loader:Loader = new Loader();

my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));

my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

function onLoaderInit(e:Event):void{


addChild(my_loader);
my_player = my_loader.content;
my_player.addEventListener("onReady", onPlayerReady);
}

function onPlayerReady(e:Event):void{
my_player.setSize(350,275);
my_player.x = 10
my_player.y = 90;
my_player.cueVideoById("otrnWuhX9x8",23);
}

play_btn.addEventListener(MouseEvent.CLICK, playVid);
function playVid(e:MouseEvent):void {
my_player.playVideo();
}


pause_btn.addEventListener(MouseEvent.CLICK, pauseVid);
function pauseVid(e:MouseEvent):void {
my_player.pauseVideo();
}

closebtn.addEventListener(MouseEvent.CLICK, closeVid);
function closeVid(e:MouseEvent):void {
my_player.stopVideo()
removeChild(my_loader)
gotoAndPlay(4);
}


This topic has been closed for replies.
Correct answer kglad

i'm pretty sure it's the loading. as soon as the video pops up, i get the error message without having pressed any buttons


if you're testing on a server:

create a new fla, add the following and test on your server.:

if you've been testing locally, adjust your fp security settings.


var my_player:Object;

var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);


function onLoaderInit(e:Event):void {

    addChild(my_loader);
    my_player=my_loader.content;
    my_player.addEventListener("onReady", onPlayerReady);
}


function onPlayerReady(e:Event):void {
    my_player.setSize(350,275);
    my_player.x=100;
    my_player.y=90;
    my_player.cueVideoById("otrnWuhX9x8",23);
}

1 reply

kglad
Community Expert
Community Expert
January 4, 2011

do you see that error with:  http://www.kglad.com/Files/Untitled-1.html

bross01Author
Participant
January 4, 2011

I don't get an error with that link. You must know something I dont?

thanks for the reply

kglad
Community Expert
Community Expert
January 4, 2011

no, i just copied your code, removed extraneous stuff and uploaded to my server.  i don't have any permission files.

are you doing anything with the video stream (like making a bitmap) or doing something with the sound?