# Embedding youtube video in flash movie

**URL:** <https://forum.kirupa.com/t/embedding-youtube-video-in-flash-movie/315945>\
**Category:** Uncategorized\
**Created:** [November 8, 2010, 3:58pm UTC](https://forum.kirupa.com/t/embedding-youtube-video-in-flash-movie/315945 "2010-11-08T15:58:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrin123](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mrin123](https://forum.kirupa.com/u/mrin123)\
**Post date:** [November 8, 2010, 3:58pm UTC](https://forum.kirupa.com/t/embedding-youtube-video-in-flash-movie/315945/1 "2010-11-08T15:58:51Z")

</div>

I need help with embedding the youtube url, this is the code I am using, the output is giving me sandbox security issues.  
Can anyone help, or if you have a better way of handling this please help.

// create a MovieClip to load the player into  
var ytplayer:MovieClip = \_root.createEmptyMovieClip(“ytplayer”, 1);

// create a listener object for the MovieClipLoader to use  
var ytPlayerLoaderListener:Object = {  
onLoadInit: function() {  
// When the player clip first loads, we start an interval to  
// check for when the player is ready  
loadInterval = setInterval(checkPlayerLoaded, 250);  
}  
};

var loadInterval:Number;

function checkPlayerLoaded():Void {  
// once the player is ready, we can subscribe to events, or in the case of  
// the chromeless player, we could load videos  
if (ytplayer.isPlayerLoaded()) {  
ytplayer.addEventListener(“onStateChange”, onPlayerStateChange);  
ytplayer.addEventListener(“onError”, onPlayerError);  
clearInterval(loadInterval);  
}  
}

function onPlayerStateChange(newState:Number) {  
trace("New player state: "+ newState);  
}

function onPlayerError(errorCode:Number) {  
trace("An error occurred: "+ errorCode);  
}

// create a MovieClipLoader to handle the loading of the player  
var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();  
ytPlayerLoader.addListener(ytPlayerLoaderListener);

// load the player  
ytPlayerLoader.loadClip(“[http://www.youtube.com/v/ghITcSYgEJ4?fs=1&hl=en\_US](http://www.youtube.com/v/ghITcSYgEJ4?fs=1&hl=en_US)”, ytplayer);

The output I am getting is

\*\*\* Security Sandbox Violation \*\*\*  
SecurityDomain ‘[http://s.ytimg.com/yt/swf/cps-vfltOO9yS.swf](http://s.ytimg.com/yt/swf/cps-vfltOO9yS.swf)’ tried to access incompatible context ‘file:///CINEMAC10330A/Users/msinha/Desktop/bathFitters/youtubeTest.swf’
