Reputation: 15494
Im using the bulkloader library on AIR to download an image, then using the AS3corelib im trying to save the file locally using:
var byteArray:ByteArray = jpgEncoder.encode( loader.getContent("IMG_0004.JPG") );
stream.writeBytes(byteArray);
stream.close();
But im getting this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Bitmap@8349a81 to flash.utils.ByteArray.
I have no idea how to solve this.
Upvotes: 0
Views: 2374
Reputation: 1264
DomingoSL, so your original prob was solved and now your problem is jpeg encoding. yes the jpeg encoder in the standard library is very slow. its the slowest encoder you could ever use. read it up on: http://www.bytearray.org/?p=775. Hint: read all the comments and youll get your answer to silent saves.
Upvotes: 1
Reputation: 18193
The encode
function wants a BitmapData
object, but you're giving it a Bitmap
.
So you should just be able to do this:
var byteArray:ByteArray = jpgEncoder.encode( Bitmap(loader.getContent("IMG_0004.JPG")).bitmapData );
Upvotes: 3