I have followed Lee’s tutorials on saving snapshot from webcam, but now I found out that I need it to be in a normal swf file rather than an air application. How could I change the code here?
import com.adobe.images.PNGEncoder;
import flash.filesystem.*;
var cam:Camera = Camera.getCamera();
var video:Video = new Video(240,180);
cam.setQuality(0, 100);
video.attachCamera(cam);
//video.x = -52.5;
frame.addChild(video);
btn.addEventListener(MouseEvent.CLICK,saveImage);
var count:int = 0;
//how to start from last number;
var scale:Number = .45;
var m:Matrix = new Matrix();
m.scale(scale,scale);
function saveImage(e:MouseEvent):void {
var bmd:BitmapData = new BitmapData(60,80,false);
bmd.draw(video,m);
var ba:ByteArray = PNGEncoder.encode(bmd);
var file:File = File.desktopDirectory.resolvePath("card" + count++ +".png" );
var fileStream:FileStream = new FileStream();
fileStream.open(file,FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.close();
}
I wanted to save the snapshot to a folder where my swf is.
Currently the code save the picture from 0 every time i open the swf. How can I save the filename after the last image in that folder?