File Open Dialog

mdotedot

  • Posts: 1640
Hello All,

Today I finished my FileOpen Dialog behavior.

Demo Stencyl File



The behavior is on StencylForge.

Works on:
  • Flash
  • Windows
  • Mac OSX
  • Android
  • iOS

Currently only tested with images. Those images are hard to find on mobile-raw-directory structure and you can better use one of the exensions.

Have Fun.

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

LIBERADO

  • *
  • Posts: 2716
Thanks for sharing. I would like to have a FileSave Dialog behavior, too.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

mdotedot

  • Posts: 1640
Thanks Liberado !

Not sure if this is what you are looking for : http://community.stencyl.com/index.php/topic,44944.0.html

My goal is to have an in-game editor and in-game loading of resources and that was sparked the development of the behaviors.

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

LIBERADO

  • *
  • Posts: 2716
I mean a behavior or an extension which allows the user (the player) to open in anytime a window to select the folder in which to save an image (stored in a image attribute) or a text (stored in a list attribute) by creating an image file or a text file in the selected folder. (not only in the "extras" folder.)

« Last Edit: October 29, 2015, 01:57:17 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

mdotedot

  • Posts: 1640
Hello Liberado,

When you use the FileOpen and replace the load trigger into saveimage trigger and make this code in the trigger event:
(_Image is a block like set Image to [image from [self])
Code: [Select]
var bitmapdata=_Image;

var b:haxe.io.Bytes = bitmapdata.encode("png", 1);

var filename:String=Sys.getCwd()+_Separator+"MyTest.png";

trace("Saving to : "+filename);

var fo:sys.io.FileOutput = sys.io.File.write(filename, true);

fo.writeBytes(b, 0, b.length );

fo.close();


Flash will not allow it.
Android/ios security issues as well. Maybe in local but that is not what you are after I guess.

Worked on Mac OSX and Windows.

Either way the upload works for all targets and is what I’m aiming for since it is platform independent and acts like a repository for my game(s) that is device-independent.

Hope this helps in saving to native!

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

purplelava

  • Posts: 82
wonderful. thanks.

Donni11

  • *
  • Posts: 2182
Awesome ! This is exactly what I needed for my game. Thanks :) !

FYI: the Dropbox link is broken, error 404.
Peace

LIBERADO

  • *
  • Posts: 2716
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

mdotedot

  • Posts: 1640
@Donni: Sorry was experimenting for Liberado. Is fixed again (With code for save deactivated)

@Rest: Thanks :D
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

merrak

  • *
  • Posts: 2644
I really needed something like this -- Thanks for sharing!

Tested on Linux and it worked.

Donni11

  • *
  • Posts: 2182
@mdotedot , is there anyway to make this work with Audio as well ? The user ( in - game player ) can choose a audio file to upload and use it as the background music.
Peace

mdotedot

  • Posts: 1640
Hello Donni11,

Did you try it? What did you try? Upload is really just bytes and as long as you can extract bytes from the audio it would not be a problem. Look in this post on how to upload : http://gamedotdevelopment.blogspot.nl/2016/01/haxe-stencyl-exporting-image-to-png-and.html

Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Donni11

  • *
  • Posts: 2182
Oh , I not talking about uploading it to a server , just uploading it to the game ( file open , this behavior ).
Peace

mdotedot

  • Posts: 1640
Replace the code where it loads the image :
Code: [Select]
var img=sys.io.File.getBytes(_SelectedFile);
var bm = BitmapData.loadFromHaxeBytes(img);
...

with code found here: http://gamedotdevelopment.blogspot.nl/2016/01/haxe-stencyl-playing-ogg-file-from.html

Of course you need to change the filter to search for *.ogg

Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Donni11

  • *
  • Posts: 2182
Peace