If you want to encode a byte array of the loaded image, you can use the Base64Encoder class from mx.utils Base64Encoder .
Sort of:
var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); loader.load(new URLRequest("img.jpg")); function loadComplete(e:Event):void { loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete); var bmd:BitmapData = Bitmap(e.target.content).bitmapData; var ba:ByteArray = bmd.getPixels(new Rectangle(0,0,bmd.width,bmd.height)); var b64:Base64Encoder = new Base64Encoder(); b64.encodeBytes(ba); trace(b64.toString()); }
I had to track the class here .
Also, there is another Base64 class that I found but not tested here ... but it seems to work the same way.
Hope this helps.
source share