multicereal
02-27-2006, 01:51 PM
i want to import a file (mp3 or jpg) into my library. i made this code, it should import a file with the same name as the FLA and which is in the same document.
var dom = fl.getDocumentDOM();
dom.getTimeline().addNewLayer("Sound", "normal", true);
var fileName = flash.documents[0].name;
var filePath = flash.documents[0].path;
//get filename without extention:
aFile = fileName.split(".");
//get filepath without filename:
aPath = filePath.split(fileName);
//make a valid path:
myFile = aPath[0]+""+aFile[0]+".mp3";
//convert to valid URI
uri = encodeURIComponent(myFile);
dom.importFile(uri,true);
(when you run the command, make sure there's only one document open --> that is "documents[0]")
anyway, it should work but it says: "The import did not finish because an unknown error occurred" and "One or more files were not imported because there were problems reading them". The files are just basic mp3's or jpg's, no problem there...
anyone done this before???
var dom = fl.getDocumentDOM();
dom.getTimeline().addNewLayer("Sound", "normal", true);
var fileName = flash.documents[0].name;
var filePath = flash.documents[0].path;
//get filename without extention:
aFile = fileName.split(".");
//get filepath without filename:
aPath = filePath.split(fileName);
//make a valid path:
myFile = aPath[0]+""+aFile[0]+".mp3";
//convert to valid URI
uri = encodeURIComponent(myFile);
dom.importFile(uri,true);
(when you run the command, make sure there's only one document open --> that is "documents[0]")
anyway, it should work but it says: "The import did not finish because an unknown error occurred" and "One or more files were not imported because there were problems reading them". The files are just basic mp3's or jpg's, no problem there...
anyone done this before???