I've been trying to take a screenshot of an instance of StageWebView for websites with embedded SWF and PDF content on the Android. The method drawViewPortToBitmapData works fine for regular websites after enabling hardware acceleration in the manifest.
//create a bitmap from the webview and display it
var bitmap_data:BitmapData = new BitmapData(stage.stageWidth - 2*WEBVIEWOFFSET, stage.stageHeight - 40 - WEBVIEWOFFSET);
webView.drawViewPortToBitmapData(bitmap_data);
//remove webview and display snapshot
webView.stage = null;
var webViewBitmap:Bitmap = new Bitmap(bitmap_data);
addChild(webViewBitmap);
The previous code works for embedded content only on the emulator in the Flash IDE. The image is generated in the folder I specified in Windows but on the Android a blank image is created instead.
The API states "The behavior of this method is not guaranteed for pages that contain plugin content (such as embedded PDF and SWF files)."
I tried using Context3D instead:
var stage3D:Stage3D = webView.stage.stage3Ds[0];
stage3D.addEventListener(Event.CONTEXT3D_CREATE, context3dCreated);
stage3D.requestContext3D(Context3DRenderMode.AUTO);
function context3dCreated(evt:Event ):void {
//context 3d creation handler
var bitmap_data:BitmapData = new BitmapData(stage.stageWidth - 2*WEBVIEWOFFSET, stage.stageHeight - 40 - WEBVIEWOFFSET);
var renderContext:Context3D = Stage3D(evt.target).context3D;
trace("3D driver: " + renderContext.driverInfo);
renderContext.drawToBitmapData(bitmap_data);
renderContext.present();
//remove webview and display snapshot
webView.stage = null;
var webViewBitmap:Bitmap = new Bitmap(bitmap_data);
addChild(webViewBitmap);
}
but this approach only generates blank images on both the emulator and the device.
Does anybody know of a way to take a screenshot from a StageWebView displaying embedded SWF or PDF content? or is there a free native extension that can trigger the screenshot in Android (power + home)?