0

How do I trigger a save dialog for a static file in Flash? The file in question can be local or remote, if that's easier. In this case the file is a static image.

I'm new to AS (and SO), but am astonished by how varied and convoluted the solutions are for a problem which initially seems very straightforward.

I've had success with JPEGEncoder (along with ByteArray, BitmapData etc.) but it's extremely slow and obviously not file type agnostic.

I'm using Flash Pro CS5 and not Flex or AIR.

Bede Constantinides
  • 2,424
  • 3
  • 25
  • 28

3 Answers3

0

How do I trigger a save dialog for a static file in Flash?

If I understood your question correctly the answer is that you cannot touch any stuff on your computer on flash.

I've had success with JPEGEncoder (along with ByteArray, BitmapData etc.) but it's extremely slow

I've asked about that what is the simpliest way to get jpg from bitmapData

Adam Smith adviced to use faster alchemy based solution instead of JPEGEncoder: http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/

Community
  • 1
  • 1
Eugeny89
  • 3,797
  • 7
  • 51
  • 98
  • Thanks Eugeny. I've read about Alchemy but assumed that there must be a more sensible solution. Is it not possible to allow the user to save an image locally without reprocessing the entire image in this case? – Bede Constantinides Apr 20 '11 at 15:17
  • @bedeabc, Alchemy solution is not the only one of cause, but I belive it's the fastest. – Eugeny89 Apr 20 '11 at 15:21
  • @bedeabc:No, you cannot save image dirrectly from flash. However there's small hack. But you'll need server for that. Post content of a file you going to save to that server, e.g. to some PHP script. In that script put download headers and then print file content. It will act as if file was downloaded from that server. – Eugeny89 Apr 20 '11 at 15:26
  • Right, so it's not possible to for the user to save an image without reprocessing it. Thanks for that. I think the best solution in my case is actually the PHP server hack, or Alchemy, but I haven't yet found a good tutorial for Alchemy, which I need because of my lack of AS experience. http://last.instinct.se/graphics-and-effects/using-the-fast-asynchronous-alchemy-jpeg-encoder-in-flash/640 doesn't work for me — lots of compile errors. – Bede Constantinides Apr 20 '11 at 16:05
  • @bedeabc: here's a tutorial http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/ – Eugeny89 Apr 20 '11 at 18:04
0

You can save a file through Flash using the FileReference class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html

As for encoding, the JPEGEncoder can be quite slow due to the quality setting. Setting it to 100% should speed it up. PNGEncoder is quicker though, or use the alchemy based solution proposed by Eugeny89

divillysausages
  • 7,883
  • 3
  • 25
  • 39
0

You may have a look on the following: http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/

michael
  • 1,160
  • 7
  • 19
  • so it's possible to download file without any hacks with server! That's cool! – Eugeny89 Apr 20 '11 at 15:52
  • Yes, if the flash player is version 10 or above. – michael Apr 20 '11 at 15:58
  • Thanks for the reply but I've tried it and it's unacceptably slow even on an i7 system for the images in question. Alchemy is fast enough but I'm not confident with Flash and I'm yet to find a good quality tutorial on using it. – Bede Constantinides Apr 20 '11 at 16:09
  • @bedeabc, you should use alchemy if you want to save the image much faster. The url that I mentioned above is how to save a file locally using flash. You can combine them for your purpose. – michael Apr 20 '11 at 16:55