カメラで撮ってpngをローカルに保存 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, 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, 340);
- bd.draw(button);
- (new FileReference()).save(
- PNGEncoder.encode(bd),
- 'capture.png'
- );
- });
- }
- }
- }
カメラで撮ってpngをローカルに保存 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 = 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'
- );
- });
- }
- }
- }
カメラで撮ってpngをローカルに保存 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(300, 300);
- 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 = 300;
- 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'
- );
- });
- }
- }
- }
カメラで撮ってpngをローカルに保存 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, 240);
- v.attachCamera(cam);
- v.x = 50;
- v.y = 50;
- this.addChild(v);
- var button:Sprite = new Sprite();
- // button.graphics.lineStyle(0, 0xa0a0a0);
- button.graphics.beginFill(0xAAAAAA);
- button.graphics.drawRect(0, 0, 100, 30);
- button.graphics.endFill();
- button.x = 50;
- button.y = 300;
- this.addChild(button);
- var tf:TextField = new TextField();
- var tfFormat:TextFormat = new TextFormat();
- tfFormat.size = 16;
- tfFormat.font = "Osaka";
- tf.text = "撮影&保存";
- tf.setTextFormat(tfFormat);
- tf.y = 3;
- tf.x = 3;
- tf.autoSize = TextFieldAutoSize.LEFT;
- tf.height = 22;
- button.addChild(tf);
- 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'
- );
- });
- }
- }
- }
notice: 
