Highlighted

cameraroll permission

Explorer ,
Nov 09, 2017

Copy link to clipboard

Copied

whats wrong with my code here?

import flash.events.PermissionEvent

import flash.permissions.PermissionStatus;

import flash.media.CameraRoll;

var cameraRoll:CameraRoll;

function checkPermission (e:Event=null):void

{

if (CameraRoll.permissionStatus != PermissionStatus.GRANTED) {

  cameraRoll.addEventListener(PermissionEvent.PERMISSION_STATUS, PermissionEventFunc)

} else {

  saveToCameraRoll()

}

}

function PermissionEventFunc(e: PermissionEvent): void {

  if (e.status == PermissionStatus.GRANTED) {

  saveToCameraRoll()

  } else {

  // permission denied

  }

function saveToCameraRoll (evt:Event=null):void

{

   var bitmap_data:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight);

  bitmap_data.draw(stage);

  cameraRoll.addBitmapData(bitmap_data);

 

}

TOPICS
Development

Views

423

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

cameraroll permission

Explorer ,
Nov 09, 2017

Copy link to clipboard

Copied

whats wrong with my code here?

import flash.events.PermissionEvent

import flash.permissions.PermissionStatus;

import flash.media.CameraRoll;

var cameraRoll:CameraRoll;

function checkPermission (e:Event=null):void

{

if (CameraRoll.permissionStatus != PermissionStatus.GRANTED) {

  cameraRoll.addEventListener(PermissionEvent.PERMISSION_STATUS, PermissionEventFunc)

} else {

  saveToCameraRoll()

}

}

function PermissionEventFunc(e: PermissionEvent): void {

  if (e.status == PermissionStatus.GRANTED) {

  saveToCameraRoll()

  } else {

  // permission denied

  }

function saveToCameraRoll (evt:Event=null):void

{

   var bitmap_data:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight);

  bitmap_data.draw(stage);

  cameraRoll.addBitmapData(bitmap_data);

 

}

TOPICS
Development

Views

424

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 09, 2017 0
Explorer ,
Nov 09, 2017

Copy link to clipboard

Copied

fixed it

import flash.events.PermissionEvent;

import flash.media.CameraRoll;

import flash.permissions.PermissionStatus;

var cameraRoll: CameraRoll

cameraRoll = new CameraRoll()

function checkPermission (e:Event=null):void

{

if (CameraRoll.permissionStatus != PermissionStatus.GRANTED) {

  cameraRoll.addEventListener(PermissionEvent.PERMISSION_STATUS, function (e: PermissionEvent): void {

  if (e.status == PermissionStatus.GRANTED) {

  saveToCameraRoll()

  } else {

  // permission denied

  }

  });

  try {

  cameraRoll.requestPermission();

  } catch (e: Error) {

  // another request is in progress

  }

} else {

  saveToCameraRoll()

}

}

function saveToCameraRoll(): void {

  //The bitmapData can be tweaked with different values until you get the coordinates you need, for now it takes all the available screen.

  var myBitmapData: BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);

  myBitmapData.draw(stage); //Instead of stage I would suggest a container or hide all the UI elements you don't need when the Timer has completed, so the photo will be clean.

  cameraRoll.addBitmapData(myBitmapData);

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 09, 2017 2