halfasleeps
03-12-2008, 08:49 PM
when ever I create a File inside a function in adds funciton Function() {} before and after my file path.
say I have this function:
var tmpStr:String;
var tmpArr:Array;
function copyFile(file){
trace("Attempting to copy file");
var sourceFile:File = file;
trace("sourceFile:"+sourceFile);
tmpStr = file.url;
tmpArr = tmpStr.split("/");
tmpStr = tmpArr[tmpArr.length-1];
trace("new file:SideBarAssets/"+tmpStr);
var destination:File = File.desktopDirectory;
destination = destination.resolvePath("SideBarAssets/"+tmpStr);
trace("destination:"+destination);
try
{
sourceFile.copyTo(destination, true);
trace("copied file");
}
catch (error:Error)
{
trace("Error:"+error.message)
}
}
this function should copy any file I pass to a folder on my desktop called "SideBarAssets".
but since I defined this in a function instead I get a folder called function Function () {} on my desktop and inside that I get another folder called SideBarAssets inside that I get another folder with the name of what the file should be for instance myfile.jpg and inside that folder I get a file named function Function () {}
very very strange
say I have this function:
var tmpStr:String;
var tmpArr:Array;
function copyFile(file){
trace("Attempting to copy file");
var sourceFile:File = file;
trace("sourceFile:"+sourceFile);
tmpStr = file.url;
tmpArr = tmpStr.split("/");
tmpStr = tmpArr[tmpArr.length-1];
trace("new file:SideBarAssets/"+tmpStr);
var destination:File = File.desktopDirectory;
destination = destination.resolvePath("SideBarAssets/"+tmpStr);
trace("destination:"+destination);
try
{
sourceFile.copyTo(destination, true);
trace("copied file");
}
catch (error:Error)
{
trace("Error:"+error.message)
}
}
this function should copy any file I pass to a folder on my desktop called "SideBarAssets".
but since I defined this in a function instead I get a folder called function Function () {} on my desktop and inside that I get another folder called SideBarAssets inside that I get another folder with the name of what the file should be for instance myfile.jpg and inside that folder I get a file named function Function () {}
very very strange