Output JPG from webpage using jpegencoder?

Related to my last question on this forum, but this is a query on what my approach to a problem should best be. I want a someone using my .swf from a browser to be able to download a “snapshot” of the swf onto their machine as a .jpg file.

I know that its possible to do this with server side PHP, as described in this thread, and a couple of blogs.

But is it possible to do it just with client-side .swf & code? I can imagine a couple of ways of doing this:

  1. sending the data to a javascript function on the page (if there’s no limit on ho much you can send to a JS function via this method, which I don’t know) This seems a very clunky way of doing it*

  2. using a FileReference:


 	var fr:FileReference = new FileReference();
 	fr.save(jpgStream, "copy.jpg");

…works from stand-alone FlashPlayer, but could it work from the browser? Hasn’t worked for me yet.

Though I’m sure I remember one of the chart libraries (amLine?) doing this. Maybe they did use PHP - but I thought not …

Thanks in advance

  • with IE before version 9 you could “force” a download of text to a file using javascript - but not on other browsers and this was no doubt seen as a security risk of IE. May have answered my own question there :S