Hello,
I’m using the jpgEncoder for a webcam snapshot app, my script was running right when my code was into my FLA on a layer, BUT I wanted to take it away in a document class, and now I’m having 2 issues :
a) when I shot a picture, the image doesnt stay frozen even with the line [attachCamera(null)]
b) I get a white image saved on my server
Here is my code so far :
public var jpgEncoder:JPGEncoder=new JPGEncoder(90);
public var ba:ByteArray=null;
public var cam:Camera=Camera.getCamera();
public var retourVideo:Video=new Video();
private function addCam():void {
var cam:Camera=Camera.getCamera();
cam.setMode(515, 386, 24, true);
cam.setQuality(0,100);
if (cam.muted) {
Security.showSettings(SecurityPanel.DEFAULT);
}
var retourVideo:Video=new Video(515,386);//Video(cam.width, cam.height);
retourVideo.attachCamera(cam);
retourVideo.x = -150;
retourVideo.y = 15;
retourVideo.rotation =-3;
magMask.addChild(retourVideo);
}
public function snap(e:MouseEvent):void {
var bmd:BitmapData=new BitmapData(retourVideo.width,retourVideo.height,false);
bmd.draw(retourVideo,new Matrix());
ba=jpgEncoder.encode(bmd);
var header:URLRequestHeader=new URLRequestHeader("Content-type","application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("upload.php?filename="+filename);
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method=URLRequestMethod.POST;
jpgURLRequest.data=ba;
sendToURL(jpgURLRequest);
snapAgain.visible=true;
snapNow.visible=false;
BoSnap=true;
retourVideo.attachCamera(null);
}
public function retake(e:MouseEvent):void {
retourVideo.attachCamera(cam);
snapAgain.visible=false;
snapNow.visible=true;
BoSnap=false;
}
Can you please look at my code and help me ?
Thanks :bu: