In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Live Keying w/ YouTube HD support

because I can.
Get Adobe Flash player
by bradsedito 02 May 2012
    Embed
/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nmm1
 */






package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.media.*;
    import flash.net.*;
    import flash.system.*;
    
    [SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#000000")]
    
    
    public class Main extends Sprite 
    {
        public  var sSW:Number = new Number( stage.stageWidth  )   // 1000/2 )
        public  var sSH:Number = new Number( stage.stageHeight )  // 0618/2 )
        private var L:Loader ;
        private var _p:Object ;
        private var _SC:Sprite = new Sprite ;
        private var _S:Sprite = new Sprite ;
        private var _canvas:BitmapData = new BitmapData ( sSW/2 , sSH/2 , true , 0 ) ; 
        
        public function Main() 
        {
            Security.allowInsecureDomain("*");
            Security.allowDomain("*");
            Security.allowDomain("www.youtube.com");
            L = new Loader ( ) ;
            L.contentLoaderInfo.addEventListener ( Event.INIT , onInit ) ;
            L.load ( new URLRequest ( "http://www.youtube.com/apiplayer?version=3" ) , new LoaderContext ( true ) ) ;
            _SC.addChild ( L ) ;
            
            var camera:Camera;
            var video:Video;
            camera = Camera.getCamera();
            if (camera != null) {
                
                camera.setMode ( 320*2, 240*2, stage.frameRate );
                
                video = new Video ( 320, 240 );
                video.attachCamera ( camera ) ;
                
                _S.addChild ( video ) ;
                
                _SC.addChild ( new Bitmap ( _canvas ) ) ;
                
            }
            
            _SC.x = ( stage.stageWidth - 320 ) / 2 ;
            _SC.y = ( stage.stageHeight - 240 ) / 2 ;
            addChild ( _SC ) ;
            
        }
        
        private function onInit ( e:Event ) :void {
            _p = L.content ; 
            L.content.addEventListener ( "onReady" , onReady ) ;
        }
        
        private function onReady ( e:Event ) :void {
            _p.setSize ( sSW, sSH ) ;
            _p.loadVideoById ( "lB95KLmpLR4", 0, "hd720" ) ;
            addEventListener ( Event.ENTER_FRAME , Run ) ;
        }
        
        public function Run ( e:Event ):void {
            _canvas.fillRect ( _canvas.rect , 0 ) ;
            _canvas.draw ( _S ) ;
            _canvas.threshold ( _canvas , _canvas.rect , new Point , "<" , 0x60 , 0 , 0x0000FF , false ) ;
        }        
        
    }
    
}