Image.ScreenCapture.toBmpAsync() This page was last modified over 30 day(s) ago and has 0 comment(s)


Back to Image.ScreenCapture Class Summary

Availability
Windows, Mac OSX

Usage
mdm.Image.ScreenCapture.toBmpAsync(x:Number, y:Number, width:Number, height:Number, filePath:Number):void

Parameters
x:Number - X coordinate of area to be captured
y:Number - Y coordinate of area to be captured
width:Number - Width of area to be captured in pixels
height:Number - Height of area to be captured in pixels
filePath:String - Location of BMP file to be created

Returns
Nothing

Description
Saves a BMP snapshot of the defined desktop area.

Notes
This is asynchronous version of mdm.Image.ScreenCapture.toBmp method. In order to be notified about results of using this method (either success or failure) you will need to create event listeners on mdm.Image.ScreenCapture object instance (please see example for details of implementation).
If alpha blending has been enabled, this command will not capture the actual Projector. Please use mdm.Image.ScreenCapture.toBmpAlt instead.

Example Code
// there are two types of events
// that we could listen in mdm.Image.ScreenCapture object
const COMPLETE:String = "onComplete";
const IO_ERROR:String = "onIOError";
// the variable that will contain a path of bitmap to be created
var path:String = null;
//
// on button click make screen shot
//
function buttonClickHandler(event:MouseEvent):void
{

// add event handlers to mdm.Image.ScreenCapture
mdm.Image.ScreenCapture.addEventListener(COMPLETE, onCompleteHandler);
mdm.Image.ScreenCapture.addEventListener(IO_ERROR, onIOErrorHandler);
// compute path and assign it to variable for later use
path = mdm.Application.path+"ScreenCaptureToBmpAsync.bmp";
// captureRect is flash.geom.Rectangle instance that holds information
// about size and location of area to be captured
mdm.Image.ScreenCapture.toBmpAsync(captureRect.x,
captureRect.y,
captureRect.width,
captureRect.height,
path);
}
//
function onCompleteHandler(event:Event):void
{
// remove listeners
mdm.Image.ScreenCapture.removeEventListener(COMPLETE, onCompleteHandler);
mdm.Image.ScreenCapture.removeEventListener(IO_ERROR, onIOErrorHandler);
// we should get file at path being created by screen capture
var exists:Boolean = mdm.FileSystem.fileExists(path);
if(exists)
{
if(path.indexOf(" ") > 0) path = "\""+path+"\"";
mdm.MacShell.exec("open "+path);
} else
{
// file does not exists for some reason
throw new Error("Failed to capture file at path: "+path);
}
}
//
function onIOErrorHandler(event:Event):void
{
// remove listeners
mdm.Image.ScreenCapture.removeEventListener(COMPLETE, onCompleteHandler);
mdm.Image.ScreenCapture.removeEventListener(IO_ERROR, onIOErrorHandler);
// let error to be handled by global uncaugh error handler here
throw new Error("Failed to capture screen to file at path: "+path);
}

mdm.Image.ScreenCapture Class Example Downloads
No Example Downloads Available


Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page