Hi there...I'm pretty much the rookiest rookie when it comes to Flash.
Here's the actionscript (3):
// Here's the dumb-dumb:
/*****************************************************************/
/*****************************************************************/
function captureImage(e:MouseEvent):void {
// The video still-image is captured and drawn...but at 320x240? Oh, and the real kicker is that it gets squeezed (resized), not cropped.
bitmapData.draw(video);
}
/*****************************************************************/
/*****************************************************************/
// Here's the other relevant code...
/*****************************************************************/
var bandwidth:int = 0;
var quality:int = 100;
var myWidth:int = 320; // the width for camera, video, and bitmaps.
var myHeight:int = 320; // the height for camera, video, and bitmaps.
var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(myWidth,myHeight,30,false); // (width, height, FPS, favorSize)
var video:Video = new Video();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
// setting the video.width and video.height here makes the video appear in the desired aspect-ratio (1:1). If this is not set it defaults to 320x240.
video.width = myWidth;
video.height = myHeight;
addChild(video);
// 0xff0000 sets a red background just so I can see that the BitmapData "element" is 320x320 like it should be.
var bitmapData:BitmapData = new BitmapData(myWidth, myHeight, false, 0xff0000);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
bitmap.width=myWidth;
bitmap.height=myHeight;
addChild(bitmap);
// capture_mc is my take-a-picture button. :-)
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
So, what am I missing here. I know the makers of Flash don't insist that all images should be displayed in a 4:3 aspect ratio, right? :o)
Anyway, thanks for helping out a "n00b".
p.s. The fact that Flash uses Ctrl+Y to "redo" instead of Ctrl+Shift+Z (like Photoshop) makes me want to flash.events.destroy(flash)
, or something.
UPDATE:
I figured out how to stretch the video from 240 to 320. But there is a significant reduction in quality in doing that. Here is the code with the updated parts in BOLD:
var bitmapData:BitmapData = new BitmapData(myWidth,
240
, false, 0xff0000);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
bitmap.width=myWidth;
bitmap.height=240;
bitmap.scaleY=1.333; // ADDED scaleY
addChild(bitmap);
So I'd still like to find a solution that maximizes the quality.