forked from: Camera 640*480

by smallwind1912 forked from Camera 640*480 (diff: 9)
Cameraクラス
http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/flash/media/Camera.html

Videoクラス
http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/flash/media/Video.html
♥0 | Line 37 | Modified 2011-08-29 11:45:14 | MIT License
play

ActionScript3 source code

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

// forked from umhr's Camera 640*480
/*
 * Cameraクラス
 * http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/flash/media/Camera.html
 *
 * Videoクラス
 * http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/flash/media/Video.html
 * */
package {
    import com.bit101.components.PushButton;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.SimpleButton;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.media.Camera;
    import flash.media.Video;
    public class Main extends Sprite {
        private var _video:Video;
        private var _bitmap:Bitmap;
        private var _w:uint=640;
        private var _h:uint=480;
        public function Main() {
            var camera:Camera = Camera.getCamera();
            //カメラの存在を確認
            if (camera) {
                _bitmap = new Bitmap(new BitmapData(_w,_h));
                this.addChild(_bitmap);
                _bitmap.scaleX=0.5;
                _bitmap.scaleY=0.5;
                camera.setMode(_w,_h, 15);
                _video = new Video(_w,_h);
                _video.attachCamera(camera);
                _video.width = 160;
                _video.height = 120;
                this.addChild(_video);
                new PushButton(this, 0, 120, "Snap", atSnap);
            } else {
                trace("カメラが見つかりませんでした。");
            }
        }
        private function atSnap(event:MouseEvent):void {
            _bitmap.bitmapData.draw(_video);
            
        }
    }
}