| Previous | Next | |
Windows: Not Yet Available
Macintosh: Flash 8 or 9 AS2.0 SWF + mProjector
2.0; replacing mProjector
1.0 async
mApplication.captureScreenToJPG(filename:String) : Booleanfilename - Name of the JPG file to store the screen capture image. If an explicit path is not included, the working directory is used.
A boolean.; ; success or failure
Method; Captures the screen and saves image as a JPG file.
The following example captures the screen and on the user's machine as a JPG. First set up a MovieClipLoader object with an onLoadInit callback, call mApplication.captureScreenToJPG() with a file path for the screen grab JPG, then call the MovieClipLoader's loadClip method with the JPG path and the movieclip where you will display the JPG. If you need to capture just a piece of the screen, set the scrollRect property of the movieclip. Windows can work exactly like the Mac with the exception of needing to call a non-documented function mScreenCapture.captureScreenToJPG() on Windows instead of mApplication.captureScreenToJPG() on the Mac. The Windows only method mScreenCapture.captureScreenToJPG() is a bit more powerful than the Mac's mApplication.captureScreenToJPG() method as it has optional clipping region parameters so you have the option of not using scrollRect property of the display movie clip. mScreenCapture.captureScreenToJPG(filepath, left, top, right, bottom);
// container for screen capture
var container_x:Number = 40.0;
var container_y:Number = 40.0;
var container_width:Number = 400.0;
var container_height:Number = 250.0;
// jpeg file names
var fullPath = mApplication.getFolder() + mSystem.getPathDelimiter() + "test1.jpg"; // fullpath to file
// post process image -- scale and crop if necessary
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
var vscale, hscale:Number;
hscale = target_mc._width / container_width;
vscale = target_mc._height / container_height;
if (hscale > vscale) {
target_mc._width = container_width;
target_mc._height = target_mc._height / hscale;
} else {
target_mc._width = target_mc._width / vscale;
target_mc._height = container_height;
}
target_mc._x = container_x;
target_mc._y = container_y;
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
// grab screen
captureScreen_btn.onPress = function() {
LOG("captureScreen_btn.onPress");
_root.removeMovieClip("screen_mc");
_root.createEmptyMovieClip("screen_mc", this.getNextHighestDepth());
mApplication.captureScreenToJPG(fullPath);
image_mcl.loadClip(fullPath, screen_mc);
};mApplication.captureScreen(), mScreenCapture.captureScreenToJPG()
mProjector Class Basics -- mApplication
| Questions or Feedback? | Previous | Next |