Thursday, September 17th, 2009
So, here I am, playing with YouTube players, trying to get more than one to load in Actionscript 3. But it’s a pain, so I did a few tests and got it running fine in Actionscript 2.
My aim is to port this to Actionscript 3, but the biggest problem is the handling of the AVMs. I’ve got some tests to do to figure out the best way to separate the content, but hopefully I should have it done soon, so do watch this space. But, for all you lot out there, here’s some old school Actionscript 2 code:
class MultipleYouTubePlayers
{
private var parent:MovieClip;
public function MultipleYouTubePlayers(parent:MovieClip)
{
System.security.allowDomain( '*' );
System.security.allowDomain( 'www.youtube.com' );
System.security.allowDomain( 'youtube.com' );
System.security.allowDomain( 's.ytimg.com' );
System.security.allowDomain( 'i.ytimg.com' );
Stage.align = 'tl';
Stage.scaleMode = 'noScale';
this.parent = parent;
init();
}
private function init():Void
{
var mc1:MovieClip = parent.createEmptyMovieClip( 'mc1', parent.getNextHighestDepth() );
var mc2:MovieClip = parent.createEmptyMovieClip( 'mc2', parent.getNextHighestDepth() );
var mc3:MovieClip = parent.createEmptyMovieClip( 'mc3', parent.getNextHighestDepth() );
var player1:TZYouTubePlayer = new TZYouTubePlayer( mc1 );
var player2:TZYouTubePlayer = new TZYouTubePlayer( mc2 );
var player3:TZYouTubePlayer = new TZYouTubePlayer( mc3 );
player1.init( 'ghqjailPGOQ' );
player2.init( 'C54wqJBxrWg' );
player3.init( 'yU5W4CkZHHQ' );
mc1._y = 0;
mc2._y = player1.playerHeight + 10;
mc3._y = ( player1.playerHeight + 10 ) * 2;
}
}
And this is what it gives you:
But I need to port it to Actionscript 3, so not quite done there!!