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

カメラで撮ってpngをローカルに保存

参考 : http://blog.asial.co.jp/512
要 Flash Player 10 らしい
Get Adobe Flash player
by nacookan 13 Jan 2009
// 参考 : http://blog.asial.co.jp/512
// 要 Flash Player 10 らしい
package{
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import flash.media.*;
    import flash.net.*;
    import com.adobe.images.PNGEncoder;

    public class CameraCap extends Sprite{
        public function CameraCap():void{
            var cam:Camera = Camera.getCamera();
            if(!cam) return;
            
            var v:Video = new Video(320, 240);
            v.attachCamera(cam);
            v.x = 50;
            v.y = 50;
            this.addChild(v);

            var button:Sprite = new Sprite();
            button.graphics.lineStyle(2, 0xa0a0a0);
            button.graphics.beginFill(0xe0e0e0);
            button.graphics.drawRect(0, 0, 100, 30);
            button.graphics.endFill();
            button.x = 50;
            button.y = 300;
            this.addChild(button);

            button.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void{
                var bd:BitmapData = new BitmapData(320, 240);
                bd.draw(v);
                (new FileReference()).save(
                    PNGEncoder.encode(bd),
                    'capture.png'
                );
            });
        }
    }
}