I know that with AIR AS3 CameraRoll addBitmapData()
I am able to store a taken image to the dedicated media library of a device.
Now the question: Is there a way to create a separate browseable folder for my app to add the images to with that method? Or is there any other way to keep the images I want to store separated from other images?
EDIT: So this is how i accomplished it in the end:
var imageFile:File = File.documentsDirectory.resolvePath("DCIM/yourfolder/");
if(!imageFile.exists) imageFile.createDirectory();
imageFile = imageFile.resolvePath("yourfile.jpg");
var fileStream:FileStream = new FileStream();
fileStream.open(imageFile, FileMode.WRITE);
fileStream.writeBytes(byteArray);
fileStream.close();
AIR will allow you to access to your local filesystem. You can use the flash native File
class which has a range of air specific arguments to allow saving and moving files without a dialog and has far less security restrictions. The standard save
function will work without air but insists a dialog box.
Official documentation here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html
Ive implemented this in an old photo booth app I wrote... I will try to dig it up and post what I have.
EDIT:
Firstly, the libraries were as follows:
adobe.air.filesystem.*;
adobe.air.filesystem.events.*;
This is what the AIR implement looks like:
function saveMyFile(){
var imgFile:String
// however you define your filename;
var f:File=File.desktopDirectory.resolvePath("myfolder/" + imgFile);
//defines the directory, attaches the filename
var s:FileStream=new FileStream();
//creates the filestream
s.open(f, FileMode.WRITE);
s.writeBytes(jpgStream);
// in this case jpgStream was bitmapData var compiled from a screenshot
s.close();
}
I just had to navigate to a folder on my desktop, but I'm sure there are more thorough ways to dig in.