Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
dandoen

TransformManager with Youtube

Recommended Posts

Hi there,

 

I've been having a bit of an issue with trying to add a youtube video to the manager. The video is added correctly on the stage and starts playing as it should. But when you try to move it around somehow the Youtube player's mouse event listeners seem to be in conflict with the TransformManager's. Because when you try to drag the TransformItem, the item sticks to the mouse position (with some lag) and you can't stop the drag.

 

Here's my code:

function loadYoutubeVideo() {
  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{
my_player = e.target.content;				
my_player.addEventListener("onReady", onPlayerReady);
}  

function onPlayerReady(e:Event):void{
my_player.setSize(640,360);
my_player.loadVideoById("_OBlgSz8sSM",0);
   stage.addChild(my_player);
var item = manager.addItem(my_player);				
}

 

Thanks!

Link to comment
Share on other sites

Yes, it looks like YouTube is doing some strange stuff with the mouse and interactivity which [unfortunately] we can't control or have any influence over, but you can simply add a transparent overlay on top of the YouTube object so that it blocks the mouse interactivity. Here's an example with your onPlayerReady() function:

 

function onPlayerReady(e:Event):void{
my_player.setSize(640,360);
my_player.loadVideoById("_OBlgSz8sSM",0);
var container:Sprite = new Sprite();
var overlay:Sprite = new Sprite();
overlay.graphics.beginFill(0x000000, 0);
overlay.graphics.drawRect(0, 0, 640, 360);
overlay.graphics.endFill();
container.addChild(my_player as DisplayObject);
container.addChild(overlay);
_stage.addChildAt(container, 0);
var item = manager.addItem(container);				
}

 

Seemed to work great for me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×