i've tried to use the outputPanel.save( fileURI)
command and was wondering, why nothing happend. ok, it works if you use a simple URI, like "file:///D:test.log" but if there are special characters like spaces or hashs in it you will run into a problem. solution is, to break the path into different parts an make them url encoded:
function getDirectory(doc){
var lastSlash = doc.path.lastIndexOf("\");
var temp = doc.path.substr(0, lastSlash).split("\");
// format directory path url encoded
for (var i=1; i<temp.length; i++) temp[i] = escape(temp[i]);
return "file:///" + temp.join("/") + "/";
}
function saveTextToFile(text2save, fileName){
var fileURI = getDirectory(flash.getDocumentDOM()) + fileName;
var myOutput = flash.outputPanel;
// clear, trace, save, and hide output;
myOutput.clear();
myOutput.trace(text2save);
myOutput.save(fileURI, false);
myOutput.clear();
myOutput.trace(fileURI + " saved")
}
// example, that saves a file in the document directory
saveTextToFile("this is a basic jsfl example", "example.txt");