Posted by johnallen84 in SWF Studio V3 on Dec 16 2008, 09:34 am

I have made an application which allows a teacher to create a cartoon quickly (on a stage c.f. Flash) and then put text captions with the cartoon characters. The cartoon is then used to promote discussion in the classroom. A button can be pressed which displays the cartoon full screen. Another button can be pressed which prints the cartoon.
I know that I can save the cartoon as a jpeg using ssCore.Win.saveImage, but this saves the cartoon as the name I have included within the actionScript. I would like the user to be able to name the cartoon themselves (i.e. open the save as dialogue, name the file and direct it to their own folder). I know this can be done for text, but can it be done for a jpeg - if so, I would be grateful if someone could point me in the right direction?(Also/alternatively, is it possible save the cartoon created and then reload it back into the application.)
Hope this makes sense! Thanks


Posted by mbd in SWF Studio V3 on Dec 16 2008, 09:40 am

If you know how to present the user with the option to save a text file then you already know how to do it for Win.saveImage.

You use ssCore.App.showFileSave to allow the user to pick the location and name of the file to save, then take the response you get, which is a full path including filename and extension, and do with it as you will. If you want to use that path for ssCore.Win.saveImage you just pass it to the path parameter.

Once you've created a JPEG file, you can load it just as you would any other JPEG in Flash: MovieClip.loadMovie, MovieClipLoader.loadClip, etc.


Posted by johnallen84 in SWF Studio V3 on Dec 16 2008, 09:50 am

Thanks Derek. I think one of the problems is my limited ability with actionScript. The relevant part looks like this:

save_btn.onPress = function(){
var return_obj = ssCore.App.showFileSave({caption:"Save file", filter:"Text files|*.jpg||", filename:"default.jpg"});
ssCore.Win.show();
ssCore.Win.saveImage()
}

Am I a million miles away?
Thanks


Posted by mbd in SWF Studio V3 on Dec 16 2008, 10:05 am

Just make sure you are passing parameters to ssCore.Win.saveImage. All of the parameters for saveImage are optional except for the path parameter. However, if you are targeting a specific spot of your application you might want to specify that as well.

Here's how I would set it up:

save_btn.onPress = function()
{
   ssCore.Win.show();
   var return_obj = ssCore.App.showFileSave({caption:"Save file", filter:"Text files|*.jpg||", filename:"default.jpg"});

   if (return_obj.result)
   {
      ssCore.Win.saveImage({path:return_obj.result});
   }
}

I moved Win.show above App.showFileSave. The purpose of having Win.show here is to ensure that your window is visible before you call App.showFileSave, or another dialog, since SWF Studio will not display dialogs if the window isn't visible.

After that we check to see if the result property exists. If it does it means the user chose a path. If it doesn't it either means that the user pressed Cancel, so the result is an empty string, or an error occurred.


Posted by johnallen84 in SWF Studio V3 on Dec 16 2008, 10:13 am

Thanks very much, Derek. That all makes sense. Unfortunately, I've been called away so I'll have to continue working on this tomorrow.
In the meantime, thanks again!


Posted by jasongbrown in SWF Studio V3 on May 01 2010, 11:35 pm

Hi, Is is possible to have a stand alone exe that calls for a mc to be printed as a jpeg, where the exe is outside of the swf movie. The reason being is that I cant have the main application as an executable since it will be running in a digital signage platform that is strict about the zones it will play, the web, and sfw zones are permissible, but it wont play an exe. so the main move has to stay swf, but I could potentially call the external exe to pull the jpeg out. Is this possible to create with Swf studio? Is it possible to do this without the OS save prompt?

Thanks,
Jason Brown


Posted by northcode in SWF Studio V3 on May 02 2010, 03:38 pm

Can you run an EXE on the platform at all? For an SWF Studio EXE to be of any real use to you, you have to be able to run it.

If you can launch an EXE and pass it a parameter (like the name of the image you want) then you can extract it to disk without a prompt. The problem you're going to have is that a SWF can't use fscommand EXEC, which is how you normally call an EXE in Flash.

The only way I know that you'd be able to make this work is to create a very simple HTTP server in SWF Studio (using the TCP plugin) and have it running in the background. Your SWF could make HTTP requests for files from the server and extract the files to disk or load them directly like you would from a normal HTTP server (using loadMovie).


Posted by jasongbrown in SWF Studio V3 on May 03 2010, 10:21 am

Thanks Northcode for your response. You seem to understand what we are dealing with.

We did figure out how to call an exe from a web zone, using the right parameters and browser settings, (instead of using the fscommand to call an exe from flash since that is problematic). Does this mean that an outside SWF Studio exe can indeed extract the image desired from the running swf file?

Would you happen to have a sample of what you described below? If so, it would be most helpful.

Quoted: "The only way I know that you'd be able to make this work is to create a very simple HTTP server in SWF Studio (using the TCP plugin) and have it running in the background. Your SWF could make HTTP requests for files from the server and extract the files to disk or load them directly like you would from a normal HTTP server (using loadMovie)."

Thanks for your help.


Posted by northcode in SWF Studio V3 on May 03 2010, 12:14 pm

You'll need a feature we just added to 3.8 (binary data support for the TCP plugin) to make this work, but I'll whip up a little file server so you can see how this works. When it's ready I'll post the project and a compiled EXE for you to try. I'll also post a simple client FLA to show you how to access the web server from your SWF.


Posted by northcode in SWF Studio V3 on May 03 2010, 04:04 pm

Okay, here it is... a REALLY basic HTTP server written in ActionScript 2 using the SWF Studio TCP and FileSys plugins.

jasongbrown_webserver.zip

When a request comes in on port 80 for one of the three files I added to the layout (santa.jpg, crazy.jpg or eyechart.jpg) the little server sends the file to the client that asked for it. You'll get a 404 for anything else you make a request for.

NOTE: You won't be able to compile this and get it to work because you need the TCP.sendMsgBinary function that only exists in version 3.8 so I've included an compiled version of server.exe for you to play with. If you're a registered user, just send your serial number to support@northcode.com and ask for a copy of the 3.8 beta and we'll hook you up.

Start server.exe from the ZIP file and then fire up client.swf. There are 3 buttons in the SWF that attempt to load the various JPG files from 127.0.0.1 (the local host). You can also put "http://127.0.0.1/santa.jpg" into your browser if the web server is running to load the images.

This code does NOT do a lot of error checking, it's just for demonstration. I'll post a cleaned up version with more functionality (probably AS3) in a blog post soon.


Posted by jasongbrown in SWF Studio V3 on May 07 2010, 08:47 am

Thank you so much for your help. I will be looking at this today.