Security Sandbox Violation - 'Tried to Access Incompatible Context'
I'm sure it goes without saying, but I need help. I'm using the Vimeo API to load a video into a swf. They have provided a wrapper class, so I just pass in the proper info and it loads a video (player and all) into my swf.
Recently, however, something changed with their API and now it doesn't work. I've bugged their support people about, but stopped when I created a second test file and it worked with identical code. So now I'm left with my master file that gives me this error:
*** Security Sandbox Violation ***
SecurityDomain 'http://api.vimeo.com/moogaloop_api.swf?oauth_key=9aa764f7815523a796c2e192ce131300&clip_id=15381150&width=760&height=414&fullscreen=0&fp_version=10' tried to access incompatible context 'file:///U|/Data/Development/Flash/PLNU%20Landing%20Pages/Discover/discover.swf'
...and won't load the movie, and a test that works exactly as expected (minus an error on their [Vimeo's] end).
Maybe I need another set of eyes, maybe I'm missing something or maybe it's just dark magic. Whatever it is, I would really appreciate some advice or help as to the possible differences between the two files and their behavior. I'm out of ideas.
Thank you!
John
Master file (only the last three methods deal with the vimeo class, but I left the others just in case they're the problem):
package
{
import MoveObject;
import VimeoPlayer;
import caurina.transitions.*;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Video;
import flash.net.navigateToURL;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
public class Discover extends MovieClip
{
protected var bgMO:MoveObject;
protected var discMO:MoveObject;
protected var chalkMO:MoveObject;
protected var stuMO:MoveObject;
protected var vp:VimeoPlayer = null;
public static var anTime:Number = 2; //total time for the animation in seconds
public static var leftZone:Number = -50;
public static var rightZone:Number = 1050;
public function Discover()
{
init();
}
protected function init():void
{
addEventListener(MouseEvent.MOUSE_MOVE, checkMousePos);
addEventListener(Event.RESIZE, handleResize);
chalkLine.campusTour.addEventListener(MouseEvent.CLICK, handleVideoClick);
chalkLine.resLife.addEventListener(MouseEvent.CLICK, handleVideoClick);
chalkLine.forward.addEventListener(MouseEvent.CLICK, handleVideoClick);
// listeners to disable animation while over the directory
directory.addEventListener(MouseEvent.ROLL_OVER, function() {removeEventListener(MouseEvent.MOUSE_MOVE, checkMousePos);});
directory.addEventListener(MouseEvent.ROLL_OUT, function() {addEventListener(MouseEvent.MOUSE_MOVE, checkMousePos);});
student.ashleyData.ashleyBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
student.isaiahData.isaiahBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
student.gabriellaData.gabriellaBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
student.rocioData.rocioBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
student.justinData.justinBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
// icon button listeners
planeBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
sunBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
// social media button listeners
twitterBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
facebookBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
flickrBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
blogBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
// directory button listeners
directory.universityOverviewBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
directory.undergraduateAdmissionsBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
directory.visitBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
directory.parentsFamilyBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
directory.graduateAdmissionsBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
directory.nsoBtn.addEventListener(MouseEvent.CLICK, handleBtnClick);
vimeo.closeVimeo.addEventListener(MouseEvent.CLICK, hideVideo);
// move objects to synchronize animation
bgMO = new MoveObject(bg, -650, -500, anTime);
discMO = new MoveObject(discoverText, 145, 545.2, anTime);
chalkMO = new MoveObject(chalkLine, -765, -100, anTime);
stuMO = new MoveObject(student, -1000, -125, anTime);
getRandomStudent();
//loadProfileData();
vimeo.alpha = 0; //going to tween video into visible
vimeo.visible = false;
loading.visible = false;
leftEdge.alpha = 0;
rightEdge.alpha = 0;
Tweener.addTween(rightEdge, {alpha:.75, x:rightZone+25, time:1, delay:1})
sunBtn.useHandCursor = true;
sunBtn.buttonMode = true;
}
protected function checkMousePos(MouseEvent:Event):void
{
if(mouseX < leftZone)
{
if(!bgMO.isMoving || bgMO.dir != "right") bgMO.moveRight();
if(!discMO.isMoving || discMO.dir != "right") discMO.moveRight();
if(!chalkMO.isMoving || chalkMO.dir != "right") chalkMO.moveRight();
if(!stuMO.isMoving || stuMO.dir != "right") stuMO.moveRight();
Tweener.addTween(leftEdge, {alpha:0, x:leftZone-100, time:1});
Tweener.addTween(rightEdge, {alpha:.75, x:rightZone+25, time:1, delay: 1});
}
else if(mouseX > rightZone)
{
if(!bgMO.isMoving || bgMO.dir != "left") bgMO.moveLeft();
if(!discMO.isMoving || discMO.dir != "left") discMO.moveLeft();
if(!chalkMO.isMoving || chalkMO.dir != "left") chalkMO.moveLeft();
if(!stuMO.isMoving || stuMO.dir != "left") stuMO.moveLeft();
Tweener.addTween(rightEdge, {alpha:0, x:rightZone+100, time:1});
Tweener.addTween(leftEdge, {alpha:.75, x:leftZone-25, time:1, delay: 1});
}
}
protected function getRandomStudent():void
{
student.ashleyData.alpha = 0;
student.ashleyData.visible = false;
student.isaiahData.alpha = 0;
student.isaiahData.visible = false;
student.rocioData.alpha = 0;
student.rocioData.visible = false;
student.gabriellaData.alpha = 0;
student.gabriellaData.visible = false;
student.justinData.alpha = 0;
student.justinData.visible = false;
var numStudents:int = 6;
var rand:uint = Math.floor(Math.random() * numStudents);
var loader:Loader = new Loader();
var url:String;
var serverLoc:String;
switch(rand)
{
case 0:
url = "studentSWFs/ashley.swf";
loader.x = 90;
loader.y = 30;
student.ashleyData.alpha = 1;
student.ashleyData.visible = true;
break;
case 1:
url = "studentSWFs/isaiah.swf";
loader.x = 162.95;
loader.y = 90.45;
student.isaiahData.alpha = 1;
student.isaiahData.visible = true;
break;
case 2:
url = "studentSWFs/rocio.swf";
loader.x = 198.00;
loader.y = 57.05;
student.rocioData.alpha = 1;
student.rocioData.visible = true;
break;
case 3:
url = "studentSWFs/gabriella.swf";
loader.x = 220.00;
loader.y = 51.00;
student.gabriellaData.alpha = 1;
student.gabriellaData.visible = true;
break;
case 4:
url = "studentSWFs/justin.swf";
loader.x = 218.20;
loader.y = 61.60;
student.justinData.alpha = 1;
student.justinData.visible = true;
break;
}
//serverLoc = "/sites/all/themes/pointloma/media/";
if(serverLoc) url = serverLoc + url;
var req:URLRequest = new URLRequest(url);
loader.load(req);
student.addChildAt(loader,0);
}
protected function handleBtnClick(e:MouseEvent):void
{
var name:String = e.currentTarget.name;
switch(name)
{
//student btns
case "ashleyBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/why-plnu/meet-some-students/ashley"), "_self");
break;
case "isaiahBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/why-plnu/meet-some-students/isaiah"), "_self");
break;
case "gabriellaBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/why-plnu/meet-some-students/gabby"), "_self");
break;
case "rocioBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/why-plnu/meet-some-students/rocio"), "_self");
break;
case "justinBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/why-plnu/meet-some-students/justin"), "_self");
break;
case "planeBtn":
navigateToURL(new URLRequest("/experience/academics/academic-programs/study-abroad"), "_self");
break;
case "sunBtn":
navigateToURL(new URLRequest("/san-diego"), "_self");
break;
//social media btns
case "twitterBtn":
navigateToURL(new URLRequest("http://twitter.com/Go2PLNU"), "_blank");
break;
case "facebookBtn":
navigateToURL(new URLRequest("http://www.facebook.com/pages/San-Diego-CA/Point-Loma-Nazarene-University/26060837166"), "_blank");
break;
case "flickrBtn":
navigateToURL(new URLRequest("http://www.flickr.com/photos/plnu"), "_blank");
break;
case "blogBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/life-plnu/plnu-bloggers"), "_self");
break;
//directory btns
case "universityOverviewBtn":
navigateToURL(new URLRequest("/discover/about-plnu"), "_self");
break;
case "undergraduateAdmissionsBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions"), "_self");
break;
case "visitBtn":
navigateToURL(new URLRequest("/discover/undergraduate-admissions/visit-campus"), "_self");
break;
case "parentsFamilyBtn":
navigateToURL(new URLRequest("/experience/community/student-development/parent-connection"), "_self");
break;
case "graduateAdmissionsBtn":
navigateToURL(new URLRequest("/discover/graduate-admissions"), "_self");
break;
case "nsoBtn":
navigateToURL(new URLRequest("/discover/new-student-orientation"), "_self");
break;
}
}
protected function handleResize(e:Event):void
{
var zone:uint = 100;
leftZone = -((stage.stageWidth-1000)*.5)+zone;
rightZone = stage.stageWidth-(((stage.stageWidth-1000)*.5)+zone);
Tweener.addTween(rightEdge, {x:rightZone+100, time:1});
Tweener.addTween(leftEdge, {x:leftZone-25, time:1});
}
protected function handleVideoClick(e:MouseEvent):void
{
loading.visible = true;
if(vp == null)
{
var w:int = vimeo.width-40;
var h:int = vimeo.height-40;
vp = new VimeoPlayer("9aa764f7815523a796c2e192ce131300", 15381150, w, h);
vp.x = 20;
vp.y = 20;
vp.addEventListener(Event.COMPLETE, vimeoPlayerLoaded);
vimeo.addChild(vp);
}
}
protected function hideVideo(e:MouseEvent):void
{
Tweener.addTween(vimeo, {alpha:0, time:.5});
vimeo.visible = false;
vp.pause();
vimeo.removeChild(vp);
vp = null;
}
protected function vimeoPlayerLoaded(e:Event):void
{
loading.visible = false;
vimeo.visible = true;
Tweener.addTween(vimeo, {alpha:1, time:1});
}
}
}
Test file:
package
{
import VimeoPlayer;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class VimeoTest extends MovieClip
{
private var vp:VimeoPlayer;
public function VimeoTest()
{
loadVideoBtn.addEventListener(MouseEvent.CLICK, handleClick);
}
private function handleClick(e:MouseEvent):void
{
if(vp == null)
{
var w:int = vimeo.width-40;
var h:int = vimeo.height-40;
vp = new VimeoPlayer("9aa764f7815523a796c2e192ce131300",15381150,w,h);
vp.x = 20;
vp.y = 20;
vp.addEventListener(Event.COMPLETE, vimeoPlayerLoaded);
vimeo.addChild(vp);
}
}
private function vimeoPlayerLoaded(e:Event):void
{
trace("holy crap, it worked");
}
}
}