【連写を記録】WEB CAM

by s26
♥0 | Line 42 | Modified 2010-07-20 15:55:27 | MIT License
play

ActionScript3 source code

/**
 * Copyright s26 ( http://wonderfl.net/user/s26 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/a0nn
 */

package
{
    import flash.display.*;
    import flash.events.Event;
    import flash.geom.*;
    import flash.media.*;
    import flash.system.*;
    public class main extends Sprite {
        private var _bmp:Bitmap;
        public var _bmd:BitmapData;
        private var _cnt:int = 0;
        private var camera:Camera;
        private var video:Video;        
        public function main() {
            camera = Camera.getCamera();
            if (camera != null) {
                video = new Video(480,360);
                video.attachCamera(camera);
                init()
            }
        }
        
         
        private function init():void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            this.stage.align = StageAlign.TOP_LEFT;
            this.stage.scaleMode = StageScaleMode.NO_SCALE;
            this.stage.quality = "best";
            this.stage.frameRate = 12;        
            _bmd = new BitmapData(465, 465, false, 0x000000);
            _bmp = new Bitmap(_bmd);
            addChild(_bmp);
            addEventListener(Event.ENTER_FRAME, onEnter);
        }

        private function onEnter(evt:Event):void {
            var i:int = _cnt%10
            var j:int = (_cnt-i)/10
            var matrix:Matrix = new Matrix(0.1,0,0,0.1,48*i,36*j);
            _bmd.draw(video, matrix);
            _cnt++
            if(_cnt==130)_cnt = 0;
        }
    }
}