Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 725791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:22:39+00:00 2026-05-14T06:22:39+00:00

I’m pretty much the rookiest rookie when it comes to Flash. Here’s the actionscript

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:22:40+00:00Added an answer on May 14, 2026 at 6:22 am

    I was asked if I had found a solution to the problem and the answer is yes. I’m just copy+pasting the actionscript from my .fla so I’m not going to explain the code below (I actually can’t remember what everything does). And obviously there are objects on the stage so you won’t be able to plug and play…sorry. Feel free to explain whats going on in the comments. 🙂

    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import com.adobe.images.PNGEncoder;
    // for javascript
    import flash.external.ExternalInterface;
    
    var snd:Sound = new camerasound(); //new sound instance for the "capture" button click
    
    var bandwidth:int = 0; // Maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second.
    var quality:int = 100; // This value is 0-100 with 1 being the lowest quality. 
    
    var myWidth:int = 240;
    var myHeight:int = 240;
    
    var hiderD:BitmapData = new BitmapData(myWidth+4,myHeight+4,false,0xffffff);
    var borderBox1:Bitmap = new Bitmap(hiderD);
    borderBox1.x = 22;
    borderBox1.y = 52;
    borderBox1.width=hiderD.width;
    borderBox1.height=hiderD.height;
    
    var borderBox2:Bitmap = new Bitmap(hiderD);
    borderBox2.x = 287;
    borderBox2.y = 52;
    borderBox2.width=hiderD.width;
    borderBox2.height=hiderD.height;
    
    
    addChild(borderBox1);
    addChild(borderBox2);
    
    
    
    
    
    
    var cam:Camera = Camera.getCamera();
    cam.setQuality(bandwidth, quality);
    cam.setMode(320, myHeight, 30, true); // setMode(videoWidth, videoHeight, video fps, favor area)
    
    var video:Video = new Video();
    video.attachCamera(cam);
    video.x = -500;
    video.y = -500;
    addChild(video);
    
    // display mode ONLY
    var video2:Video = new Video();
    video2.attachCamera(cam);
    video2.x = -16;
    video2.y = 54;
    video2.width=320;
    video2.height=myHeight;
    var m:Shape = new Shape();
    m.graphics.beginFill(0x0);
    m.graphics.drawRect( 24, 54, 240, 240 ); // draw the mask
    m.graphics.endFill(); // end the fill
    video2.mask = m;
    
    addChild(video2);
    
    
    // used for sending
    var bitmapData:BitmapData = new BitmapData(320,myHeight,false,0xFF0000);
    
    // used for display
    var bitmapData2:BitmapData = new BitmapData(320,myHeight,false,0xAAAAAA);
    var bitmap2:Bitmap = new Bitmap(bitmapData2);
    bitmap2.x = 249;
    bitmap2.y = 54;
    bitmap2.width=320;
    bitmap2.height=myHeight;
    var m2:Shape = new Shape();
    m2.graphics.beginFill(0x0);
    m2.graphics.drawRect( 289, 54, 240, 240 ); // draw the mask
    m2.graphics.endFill(); // end the fill
    bitmap2.mask=m2;
    addChild(bitmap2);
    
    capture_mc.buttonMode = true;
    capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
    
    function captureImage(e:MouseEvent):void {
        snd.play();
    
        bitmapData2.draw(video);
    
        bitmapData.draw(video);
    
        warn.visible = false;
    
        save_mc.buttonMode = true;
        save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
        save_mc.alpha = 1;
    }
    
    save_mc.alpha = .5;
    
    
    function onSaveJPG(e:Event):void{
    
        saving.visible = true;
    
        var byteArray:ByteArray = PNGEncoder.encode(bitmapData);
    
        var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    
        var saveJPG:URLRequest = new URLRequest("/utilities/saveImage.aspx");
        saveJPG.requestHeaders.push(header);
        saveJPG.method = URLRequestMethod.POST;
        saveJPG.data = byteArray;
    
        var urlLoader:URLLoader = new URLLoader();
        urlLoader.addEventListener(Event.COMPLETE, sendComplete);
        urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
        urlLoader.load(saveJPG);
    
        function sendComplete(event:Event):void{
            var loader:URLLoader = URLLoader(event.target);
            ExternalInterface.call("updateImageInputWithFileName",loader.data.filename);
            warn.visible = true;
            saving.visible = false;
    
    
            setTimeout(function(){warn.visible=false},10000);
        }
        function onIOError(event:Event):void{
            saving.visible = false;
            ExternalInterface.call("error", "Error", "Could not save image." ,"There was a problem saving the image. You can try again or contact an administrator for assistance.");
        }
    }
    
    warn.visible = false;
    saving.visible = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.