Posted By

robslegtenhorst on 04/14/11


Tagged

AIR jsfl


Versions (?)

air to jsfl


 / Published in: ActionScript 3
 

  1. // create a temporary directory
  2. var tempDir : File = File.createTempDirectory();
  3.  
  4. // create a temporary file in the temporary directory called run.jsfl
  5. var tempFile : File = tempDir.resolvePath("run.jsfl");
  6.  
  7. // write the returned string from the JSFLCreate function
  8. var fs : FileStream = new FileStream();
  9. fs.open(tempFile, FileMode.WRITE);
  10. fs.writeUTFBytes(JSFLCreate($fileArray));
  11. fs.close();
  12.  
  13. // open the file with the default application
  14. tempFile.openWithDefaultApplication();
  15.  
  16. function JSFLCreate ( $fileArray : Array ) : String
  17. {
  18. var urlString : String = '';
  19. var content : String = '';
  20.  
  21. for each (var $file : File in $fileArray)
  22. {
  23. // writes the path to all the dragged in files to a string
  24. urlString += '"file://'+$file.nativePath+'",';
  25. }
  26.  
  27. // remove the trailing comma
  28. urlString = urlString.slice( 0, -1 );
  29.  
  30. // write all the paths to an array
  31. content += 'var uriArr = ['+urlString+'];';
  32.  
  33. content += 'var sl = uriArr.length;';
  34.  
  35. // use the default publish profile, this can be modified
  36. content += 'var publishProfileName = "Default";';
  37.  
  38. // create a loop which runs through all of the selected files, and publishes them.
  39. content += 'for(var i = 0; i < sl; i++){';
  40. content += 'fl.publishDocument(uriArr[i], publishProfileName);';
  41. content += '}';
  42.  
  43.  
  44. return content;
  45. }

Report this snippet  

You need to login to post a comment.