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

カメラの裏に動画表示しただけ

Get Adobe Flash player
by kuma360 31 Aug 2010
    Embed
/**
 * Copyright kuma360 ( http://wonderfl.net/user/kuma360 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eXG7
 */

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 {
        
        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 ( 320 , 240 , true , 0 ) ;
        
        public function Main() {
            
            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, 240, 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 ( 320, 240 ) ;
            _p.loadVideoById ( "iRuQitz4h10", 0, "small" ) ;
            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 ) ;
        }        
        
    }
    
}