How to send a jpg image as ByteArray
from as3 to javascript? And how to convert ByteArray
to image in javascript?
Take your DisplayObject
(Sprite
/MovieClip
/whatever) and convert it to a BitmapData:
myBitmapData.draw(mySprite);
Convert that to a PNG using adobe's AS3CoreLib
myByteArray = PNGEncoder.encode(myBitmapData);
Convert that to Base64 using Flex's Base64Encoder:
myBase64Encoder.encodeBytes(myByteArray);
Then export actionscript variables to Javascript using ExternalInterface.