Page 1 of 1

FileGetDialog syntax ?

Posted: March 26th, 2012, 1:03 am
by lougris
Hello,


I use the function fileGetDialog(title, filelist), and i would like to know the syntax to list lots of files type in the filelist parameter ?

Exemple : JPEG (*.jpg,*.jpeg)

TIFF (*.tiff)

TARGA (*.tga)


Thanks for advance


Frédéric

Re: FileGetDialog syntax ?

Posted: May 16th, 2012, 8:36 am
by micpen
Hi, with File.openDialog :

var targetFile = File.openDialog("Import File");

if (targetFile) {

var dot = targetFile.toString().lastIndexOf(".");
var extension = targetFile.toString().substr(dot,targetFile.length);
if(extension.match(new RegExp ("(png|jpg|swf)", "i")))
{
targetFile.open("r");
var TypeOfImg = targetFile.read();

LoadFile(targetFile); // function to load files

} else { alert("Invalid image format. Only these formats are accepted : .png .jpg .swf ") }

}