-
Notifications
You must be signed in to change notification settings - Fork 25
A.7. AR Screen Captures
Taking screen captures from your AR experience is super easy. All you have to do is to create a button on your html/js side which will send a message back to your AIR app. for example you can send a message like this:
AR.platform.sendJSONObject({
action: "capture_screen"
});
on the AIR side, you need to listen to the ArEvents.JS_TALK
event to know when js wants the screen capture to happen. And when this happens, you should call AR.captureScreen
so the screenshot can happen.
AR.listener.addEventListener(ArEvents.JS_TALK, onJsTalk);
private function onJsTalk(e:ArEvents):void
{
trace("onJsTalk: " + e.msg);
var obj:Object = JSON.parse(e.msg);
if(obj.action == "capture_screen")
{
AR.captureScreen(
Screenshot.CAPTURE_MODE_CAM,
"img.png" // relative path to File.applicationStorageDirectory
);
}
}
When taking the screenshot, you can decide if you want the overlay webview be also visible in the image or not by using Screenshot.CAPTURE_MODE_CAM
or CAPTURE_MODE_CAM_WEBVIEW
.
The second parameter of the AR.captureScreen
method lets you decide on the location and file name of the taken image. note that you must pass a string relative to the File.applicationStorageDirectory
directory.
Enjoy building Air apps – With ♥ from MyFlashLabs Team