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

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

参考 : http://blog.asial.co.jp/512
要 Flash Player 10 らしい
Get Adobe Flash player
by hacker_4pqz69ow 26 Apr 2009
    Embed
// forked from hacker_4pqz69ow's forked from: forked from: カメラで撮ってpngをローカルに保存
// forked from hacker_4pqz69ow's forked from: カメラで撮ってpngをローカルに保存
// forked from nacookan's カメラで撮ってpngをローカルに保存
// 参考 : 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, 280);
            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 = 350;
            this.addChild(button);

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