In my recent project, I need to get a file path where the user can specify/choose the file by using Dialog Box.
This is my code in order to do just that;
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.filesystem.File;
import flash.net.FileFilter;
import xlsxreader.Worksheet;
import xlsxreader.XLSXLoader;
public class MainClass extends MovieClip
{
var fileGet: File = new File();
var excel_loader: XLSXLoader = new XLSXLoader();
public function STRIMSMainClass()
{
var import_btn: MovieClip = MovieClip(root).powerButton_mc.utilitiesButton_mc;
import_btn.addEventListener(MouseEvent.CLICK, selectExcelFile);
fileGet = File.applicationDirectory;
fileGet.addEventListener(Event.CANCEL, fileCancel);
fileGet.addEventListener(Event.SELECT, fileSelect);
excel_loader.addEventListener(Event.COMPLETE, loadingComplete);
}
function selectExcelFile(e: MouseEvent): void
{
var fileFilter = new FileFilter("Select Excel File", "*.xls;*.xlsx;*.xlsm");
fileGet.browseForOpen("Select Excel File", [fileFilter]);
}
function fileCancel(e: Event): void
{}
function fileSelect(e: Event): void
{
excel_loader.load(fileGet.nativePath);
}
function loadingComplete(e: Event): void
{}
}
}
However, the published .exe file can not be open by my computer; it just flash and automatically close itself. I test the code before publish and it work just fine.
When I try to go through the code line by line, by delete this line var fileGet: File = new File()
and obviously any line that associate with it, the .exe file can be open just fine.
I need filesystem.File
for to get the .nativePath of the file that need to be open, so I can not exclude var fileGet: File = new File()
. This also happen in my colleague's PC.
Please help me solve this weird error that happen right now. This is my first time trying to use Adobe Animate to develop software.