Ahmed Nuaman


builder of internets ~ developer of dreams ~ tamer of Dachshunds

Another Release Of The Shiny YouTube Actionscript3 Wrapper

Ok so after some feedback on the last release of the wrapper, I’ve updated it and pushed it to Github.

There’s no need to compile the SWF yourself, I’ve done the hard work for you. Aren’t I nice?

So, here’s a quick run through on how you can use it. In this example, I’m using the chromeless player as there was an issue with it in the last release:

package
{
    import com.firestartermedia.lib.as3.display.component.interaction.ButtonSimple;
    import com.firestartermedia.lib.as3.display.component.video.YouTubePlayer;
   
    import flash.display.LoaderInfo;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.MouseEvent;
    import flash.system.Security;

    [SWF( backgroundColor="#FFFFFF" )]

    public class PlayerTest extends Sprite
    {  
        private var player:YouTubePlayer;
       
        public function PlayerTest()
        {
            stage.align         = StageAlign.TOP_LEFT;
            stage.scaleMode     = StageScaleMode.NO_SCALE;
           
            Security.allowDomain( '*' );
            Security.allowDomain( 'www.youtube.com' );  
            Security.allowDomain( 'youtube.com' );  
            Security.allowDomain( 's.ytimg.com' );  
            Security.allowDomain( 'i.ytimg.com' );
           
            init();
        }
       
        private function init():void
        {
            player = new YouTubePlayer();
           
            player.chromeless       = true;
            player.wrapperURL       = ( LoaderInfo( loaderInfo ).parameters.url ||= 'assets/swf/YouTubePlayerWrapper.swf' );;
           
            player.play( 'ghqjailPGOQ' );
           
            addChild( player );
           
            var button:ButtonSimple = new ButtonSimple();
           
            button.buttonText       = 'Pause the video';
            button.textEmbedFonts   = false;
           
            button.draw();
           
            button.addEventListener( MouseEvent.CLICK, handleClick );
           
            addChild( button );
        }
       
        private function handleClick(e:MouseEvent):void
        {
            player.pause();
        }
    }
}

So, all I’m doing here is creating a button and creating the player and when you click that button, the player pauses:

So, hope that helps. If there’s any more issues or requests, just comment back.

Where have comments gone?

Good question my old fruity. I'm now sticking any post discussions on Google+. Why? Well simply it's better. WordPress's comment system isn't very elegant and nor are ones like Disqus or Livefyre, so to save hassle I've just shipped them off to a social network, like a real boss.

Search

My social skills

Latest blog posts

  • Loading posts...

Subscribe in a reader

Latest tweets

  • Loading tweets...