I'm trying to transfer a jpeg from Flash to JavaScript. Is this even possible?
What I mean by that is: Flash is supplied an image from the user and performs some image manipulation. I then need to display that modified image in HTML. Do I need to post the image from the flash to the server and load it in html through a URL, or can I pass it directly from the flash into a javascript Image object through flash's external interface somehow?
What's the best way to do this?
Thanks.
One possible way is to encode your image to base64 and send the string via externalInterface call to JavaScript. On the JavaScript side you will need to decode the received string from base64 back to the original jpeg format.
Here a collection of tutorials to do all the bits needed:
Convert image to base64 in Actionscript: http://swati61.blogspot.de/2011/07/convert-image-to-base64-string-and-vice.html
Convert base64 to image in javascript : Base64 encoding and decoding in client-side Javascript
Communication between Actionscript and JavaScript: http://www.hariscusto.com/programming/communication-between-javascript-and-actionscript-as3-and-vice-versa/
I hope this answers your question.