Haxe, Stencyl, Windows 'Save As' Dialogue

174 Views Asked by At

I have been using a visual programming language called Stencyl to create a program for users to edit images (basically), but something I've been having difficulty with is for the user to export their image (or a text-file of the image data) once they're done editing it. There is an extension available for Stencyl which allows a program to save PNG images and .txt files to a specific place in the program folder, but I've been trying to make it so that the program opens a save as dialogue for Microsoft Windows.

After working on this for several days, I've decided to try ask others for help. I was going to post links to where I've been researching, but I've been extensively reminded that I need at least 10 reputation to post more than two links, so nevermind then. Currently, it seems that I need to use something called sys.io.FileOutput, and I've been getting most of my information on how to actually write the code from this webpage.

If anyone is able to help me with this, I would greatly appreciate it.

1

There are 1 best solutions below

0
On

While I believe Haxe by itself does not have a file dialog library, there are multiple ones out there. HaxeUI and haxeui-file-dialogs implement such a ui.

If you're compiling to Flash, actionscript used to support file opening and saving as dialogs, and it might still be implemented in Haxe's Flash support. flash.net.FileReference is what you're looking for then.

You could also simply make your own. Using sys.FileSystem, you could list all files in a folder and navigate. While it demands some work, you'll have to gage what is better, building your own solution or learning a ui library to implement it. In most cases, it's the latter, but it's not as fun.

Note that some targets prevent such file access for security reasons. Flash's addition of it many years ago caused a lot of security problems.