- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
So I downloaded the vimeo as3 api from git hub. I can create the player pretty easy in a fresh fla, but when I try to put it in my newest file I get this error.
*** Security Sandbox Violation *** SecurityDomain 'http://vimeo.com/crossdomain.xml' tried to access incompatible context 'file:////Volumes/Macintosh%20HD/Users/marc/Dropbox/%5Factiveden/flipbook/flipbook.swf'
I can’t figure out what the deal is. I’ve tried adding:
Security.allowDomain(’*’); Security.loadPolicyFile(‘http://api.vimeo.com/crossdomain.xml’);
But nothing works. Yet in a fresh FLA I paste this code and it works:
import com.vimeo.api.VimeoPlayer; var player : VimeoPlayer = new VimeoPlayer(20505353, 520, 292); addChild(player)
Anyone have any suggestions.
PS- I heard vimeo was a nightmare but this is a joke. I’m tempted to just turn my back on them.
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Author had a Free File of the Month
- Bought between 1 and 9 items
- Exclusive Author
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
I am using this file:
Security.loadPolicyFile("http://vimeo.com/moogaloop/crossdomain.xml");
I am not familiar with Vimeo, but I had similar issue with other library, which loads external assets. Try:
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = ApplicationDomain.currentDomain;
Then supply this context to your loader.
EDIT :
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
Try setting Security.allowDomain from both the parent and child swf.
Like FLEXIncubator said, I would try the LoaderContext
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
That you for your replies, but still no luck.
I tried all of the above and still nothing works. I tried to comment out all the code and only have the vimeo code, and still I get the same response. So I then started to delete my library items one by one, and found that as long as my library has an item that’s “export for actionscript” I get the error. As soon as all the “export for actionscript” MovieClips are deleted the file loads up the stupid moogaloop player and video.
Here is my code on my fla first frame:
import com.vimeo.api.VimeoPlayer; stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; //var player = new VimeoPlayer(}"0505353", 2, 640, 360); //VimeoPlayer(oauth_key:String, clip_id:int, w:int, h:int, fp_version:String='10', api_version:int=2) var player : VimeoPlayer = new VimeoPlayer(20505353, 520, 292); addChild(player)//'XXXX', 2, 640, 360And here’s the vimeo class (that they provide):
/**
* VimeoPlayer
*
* A wrapper class for Vimeo's video player (codenamed Moogaloop)
* that allows you to embed easily into any AS3 application.
*
* Example on how to use:
* var vimeo_player = new VimeoPlayer([YOUR_APPLICATIONS_CONSUMER_KEY], 2, 400, 300);
* vimeo_player.addEventListener(Event.COMPLETE, vimeoPlayerLoaded);
* addChild(vimeo_player);
*
* http://vimeo.com/api/docs/moogaloop
*
* Register your application for access to the Moogaloop API at:
*
* http://vimeo.com/api/applications
*/
package com.vimeo.api
{
import flash.net.URLRequest;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
import flash.geom.Point;
import flash.utils.Timer;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.system.Security;
import flash.system.SecurityDomain;
public class VimeoPlayer extends Sprite {
// Assets
private var container : Sprite = new Sprite(); // sprite that holds the player
private var moogaloop : Object = false; // the player
private var player_mask : Sprite = new Sprite(); // some sprites inside moogaloop go outside the bounds of the player. we use a mask to hide it
// Default variables
private var player_width : int = 400;
private var player_height : int = 300;
private var api_version : int = 2;
private var load_timer : Timer = new Timer(200);
// Events
// API v2
public static const FINISH : String = 'finish';
public static const LOAD_PROGRESS : String = 'loadProgress';
public static const PAUSE : String = 'pause';
public static const PLAY : String = 'play';
public static const PLAY_PROGRESS : String = 'playProgress';
public static const READY : String = 'ready';
public static const SEEK : String = 'seek';
// API v1
public static const ON_FINISH : String = 'onFinish';
public static const ON_LOADING : String = 'onLoading';
public static const ON_PAUSE : String = 'onPause';
public static const ON_PLAY : String = 'onPlay';
public static const ON_PROGRESS : String = 'onProgress';
public static const ON_SEEK : String = 'onSeek';
public function VimeoPlayer(clip_id:int, w:int, h:int, fp_version:String='10', api_version:int=2)
{
this.setDimensions(w, h);
Security.allowDomain('*');
Security.loadPolicyFile("http://vimeo.com/moogaloop/crossdomain.xml");
var api_param : String = '&js_api=1';
//
if (fp_version != '9')
{
switch(api_version)
{
case 2:
api_param = '&api=1';
break;
}
}
// var loaderContext : LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);
var request : URLRequest = new URLRequest("http://vimeo.com/moogaloop_api.swf?clip_id=" + clip_id + "&width=" + w + "&height=" + h + "&fullscreen=1&autoplay=0&fp_version=" + fp_version + api_param + "&cache_buster=" + (Math.random() * 1000));
var loader : Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.load(request);
}
public function destroy() : void
{
if (api_version == 2)
{
// API v2 Event Handlers
moogaloop.removeEventListener(READY, readyHandler);
moogaloop.removeEventListener(PLAY, playHandler);
moogaloop.removeEventListener(PAUSE, pauseHandler);
moogaloop.removeEventListener(SEEK, seekHandler);
moogaloop.removeEventListener(LOAD_PROGRESS, loadProgressHandler);
moogaloop.removeEventListener(PLAY_PROGRESS, playProgressHandler);
moogaloop.removeEventListener(FINISH, finishHandler);
}
else
{
// API v1 Event Handlers
moogaloop.removeEventListener(ON_PLAY, onPlayHandler);
moogaloop.removeEventListener(ON_PAUSE, onPauseHandler);
moogaloop.removeEventListener(ON_SEEK, onSeekHandler);
moogaloop.removeEventListener(ON_LOADING, onLoadingHandler);
moogaloop.removeEventListener(ON_PROGRESS, onProgressHandler);
moogaloop.removeEventListener(ON_FINISH, onFinishHandler);
}
moogaloop.destroy();
if (container.contains(DisplayObject(moogaloop))) container.removeChild(DisplayObject(moogaloop));
if (this.contains(player_mask)) this.removeChild(player_mask);
if (this.contains(container)) this.removeChild(container);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}
private function setDimensions(w:int, h:int) : void
{
player_width = w;
player_height = h;
}
private function onComplete(e:Event) : void
{
// Finished loading moogaloop
container.addChild(e.currentTarget.loader.content);
moogaloop = e.currentTarget.loader.content;
if (api_version == 2)
{
// API v2 Event Handlers
moogaloop.addEventListener(READY, readyHandler, false, 0, true);
moogaloop.addEventListener(PLAY, playHandler, false, 0, true);
moogaloop.addEventListener(PAUSE, pauseHandler, false, 0, true);
moogaloop.addEventListener(SEEK, seekHandler, false, 0, true);
moogaloop.addEventListener(LOAD_PROGRESS, loadProgressHandler, false, 0, true);
moogaloop.addEventListener(PLAY_PROGRESS, playProgressHandler, false, 0, true);
moogaloop.addEventListener(FINISH, finishHandler, false, 0, true);
}
else
{
// API v1 Event Handlers
moogaloop.addEventListener(ON_PLAY, onPlayHandler, false, 0, true);
moogaloop.addEventListener(ON_PAUSE, onPauseHandler, false, 0, true);
moogaloop.addEventListener(ON_SEEK, onSeekHandler, false, 0, true);
moogaloop.addEventListener(ON_LOADING, onLoadingHandler, false, 0, true);
moogaloop.addEventListener(ON_PROGRESS, onProgressHandler, false, 0, true);
moogaloop.addEventListener(ON_FINISH, onFinishHandler, false, 0, true);
}
// Create the mask for moogaloop
this.addChild(player_mask);
container.mask = player_mask;
this.addChild(container);
redrawMask();
load_timer.addEventListener(TimerEvent.TIMER, playerLoadedCheck);
load_timer.start();
}
/**
* Wait for Moogaloop to finish setting up
*/
private function playerLoadedCheck(e:TimerEvent) : void
{
if (moogaloop.player_loaded)
{
// Moogaloop is finished configuring
load_timer.stop();
load_timer.removeEventListener(TimerEvent.TIMER, playerLoadedCheck);
// remove moogaloop's mouse listeners listener
moogaloop.disableMouseMove();
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
dispatchEvent(new Event(Event.COMPLETE));
}
}
/**
* Fake the mouse move/out events for Moogaloop
*/
private function mouseMove(e:MouseEvent) : void
{
var pos : Point = this.parent.localToGlobal(new Point(this.x, this.y));
if (e.stageX >= pos.x && e.stageX <= pos.x + this.player_width &&
e.stageY >= pos.y && e.stageY <= pos.y + this.player_height)
{
moogaloop.mouseMove(e);
}
else
{
moogaloop.mouseOut();
}
}
private function redrawMask() : void
{
with (player_mask.graphics)
{
beginFill(0x000000, 1);
drawRect(container.x, container.y, player_width, player_height);
endFill();
}
}
public function play() : void
{
moogaloop.play();
}
public function pause() : void
{
moogaloop.pause();
}
/**
* returns duration of video in seconds
*/
public function getDuration() : int
{
return moogaloop.duration;
}
/**
* Seek to specific loaded time in video (in seconds)
*/
public function seekTo(time:int) : void
{
moogaloop.seek(time);
}
/**
* Change the primary color (i.e. 00ADEF)
*/
public function changeColor(hex:String) : void
{
moogaloop.color = uint('0x' + hex);
}
/**
* Load in a different video
*/
public function loadVideo(id:int) : void
{
moogaloop.loadVideo(id);
}
public function setSize(w:int, h:int) : void
{
this.setDimensions(w, h);
var size : Object = new Object();
size.width = w;
size.height = h;
moogaloop.size = size;
this.redrawMask();
}
/**
* API v2 Event Handlers
*/
private function readyHandler(event:Event) : void
{
trace('readyHandler');
}
private function playHandler(event:Event) : void
{
trace('playHandler');
}
private function pauseHandler(event:Event) : void
{
trace('pauseHandler');
}
private function seekHandler(event:Event) : void
{
trace('seekHandler');
}
private function loadProgressHandler(event:Event) : void
{
trace('loadProgressHandler');
}
private function playProgressHandler(event:Event) : void
{
trace('playProgressHandler');
}
private function finishHandler(event:Event) : void
{
trace('finishHandler');
}
/**
* API v1 Event Handlers
*/
private function onPlayHandler(event:Event) : void
{
trace('onPlayHandler');
}
private function onPauseHandler(event:Event) : void
{
trace('onPauseHandler');
}
private function onSeekHandler(event:Event) : void
{
trace('onSeekHandler');
}
private function onLoadingHandler(event:Event) : void
{
trace('onLoadingHandler');
}
private function onProgressHandler(event:Event) : void
{
trace('onProgressHandler');
}
private function onFinishHandler(event:Event) : void
{
trace('onFinishHandler');
}
}
}
Any ideas?
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Author had a Free File of the Month
- Bought between 1 and 9 items
- Exclusive Author
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
So you have some kind of collision between vimeo and your objects in the library?
Have you tried loading it as external swf in your application?
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
Tean said
So you have some kind of collision between vimeo and your objects in the library? Have you tried loading it as external swf in your application?
It kind of defeats the point I think. When I call the vimeo class it loads their crappy player with is a separate swf. It just seems like excessive loading for loading sake (not ver efficient)
Dumb… (not you them).
I’ll give it a try though and see if it works.
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
DANG IT ! I still get the same security error.
*** Security Sandbox Violation *** SecurityDomain 'http://api.vimeo.com/crossdomain.xml' tried to access incompatible context 'file:////Volumes/SSD/Users/marc/Downloads/vimeo%2Dplayer%2Dapi%2Dd819f22%2D1/actionscript/deploy/test.swf'
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Author had a Free File of the Month
- Bought between 1 and 9 items
- Exclusive Author
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Really dont know what to tell you..
Try using my url request:
Security.loadPolicyFile("http://vimeo.com/moogaloop/crossdomain.xml");
var request:URLRequest = new URLRequest("http://api.vimeo.com/moogaloop_api.swf?oauth_key=" + _oauth_key + "&clip_id=" + int(_videoUrl) + "&width=" + _player_width + "&height=" + _player_height + "&fullscreen=0&fp_version=" + _fp_version);
