Beautifl - Flash Gallery

Thumbnail : マトリックスの世界へようこそ
マトリックスの世界へようこそ
ton 2009-09-04 All rights reserved

再生するにはFlash Playerが必要です。デスクトップのブラウザでご覧ください。

//なんとなくマトリックスっぽいなにか
//The 25-Line ActionScript Contest
//January 2009 Finalists! Entry 001
//をすこーーし改造
//このflashはwebカメラが必要です
//Lucida Console というフォントを使っています 持ってない方はこちらからフリーでダウンロードできるようです
//http://www.webpagepublicity.com/free-fonts-l3.html#Free%20Fonts
package {
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.text.TextField;
    import flash.text.TextFormat;

    [SWF(backgroundColor=0x000000)]
    public class AACamera extends Sprite {
        private const W:int = 465;
        private const H:int = 465;
        
        private var video:Video = new Video(W / 5, H / 8);
        private var bmd:BitmapData = new BitmapData(W / 5, H / 8, false);
        private var charList:Array = [" ",".",":","-",",",";","\"","。","i","t","1","+","o","3","b","8","0","%","$","#"];
        private var charLength:int = charList.length;
        private var tf:TextField = new TextField();
        private var tt:TextFormat = new TextFormat("Lucida Console", 8, 0x18793c);
        public function AACamera():void {
            tf.width = tf.height = W;
            addChild(tf);
            video.attachCamera(Camera.getCamera());
            addChild(video);
            addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
        }
        
        private function onEnterFrameHandler(e:Event):void {
            bmd.draw(video);
            var str:String = "";
            var h:int = bmd.height;
            var w:int = bmd.width;
            for (var i:int = 0; i < h; i++) {
                for (var j:int = 0; j < w; j++) {
                    str += charList[int((bmd.getPixel(j, i) / 0xffffff) * (charLength - 1))];
                }
                str += "\n";
            }
            tf.text = str;
            tf.setTextFormat(tt);
        }
    }
}