How do you download multiple images from a server and store them on in the application directory in Flash IDE , Adobe AIR?
Specifically, I am using AMFPHP to pull the paths out of a DB and download them to the application directory.
How do you download multiple images from a server and store them on in the application directory in Flash IDE , Adobe AIR?
Specifically, I am using AMFPHP to pull the paths out of a DB and download them to the application directory.
If I got this right, you're trying to download some images with an AIR app and put the pictures in a folder in Flash CS4 ?
If so, it depends a little bit on your os, so you need to make sure you get your paths right. Do a if/else and check for systrayIcon or dockIcon for that.
You could tackle this multiple ways.
You could just use the File API that comes with AIR to save the files to disk in the right location, or to a temporary location then copy them to the flash folder.
You could write downloaded files to disk using AIR and write a tiny JSFL script and call it on the fly. Something like:
var jsfl:String = 'var files = [';
for(var i:int = 0 ; i < downloadedFiles.length; i++){
if(i < downloadedFiles.length-1) jsfl += '"'+downloadedFiles[i]+'",';
else jsfl += '"'+downloadedFiles[i]+'"];\n';
}
jsfl += 'for(var i = 0 ; i < files.length; i++ ){\n';
jsfl += '\tFLfile.copy(files[i],fl.configURI+'StockImages/'+files[i].substr(files[i].lastIndexOf('/')+1));\n}';
I'm assuming downloadedFiles is the name of the array that stores the paths to the written images. This should result in a jsfl script like:
var files = ["file:///path/file_01.jpg","file:///path/file_02.jpg","file:///path/file_03.jpg"];
for(var i = 0 ; i < files.length; i++ ){
FLfile.copy(files[i],fl.configURI+'StockImages/'+files[i].substr(files[i].lastIndexOf('/')+1));
}
This should copy the images to something close to /Users/{username}/Library/Application Support/Adobe/Flash CS3 or FlashCS4/{language}/Configuration/StockImages/ on mac os and /Users/{username}/Local Settings/Application Data/Adobe/Flash CS3 or FlashCS4/{language}/Configuration/StockImages/ on windows You can then call Flash with the path to the jsfl file as an argument.
Another option would be to write a command line tool that receives 2 arguments: some binary data and a file path (string)
You could then write a Flash Panel(a swf that makes jsfl calls and lives in the WindowSWF folder) and use as3 to load the images and call the commandline tool to write them to disk. You would use the undocummented FLfile.runCommandLine to do that.
The options depend on your level of comfort with AIR/JSFL/some other language to write a commandline tool.
I am not sure what is the outcome of all this... there might be easier ways.