有沒有人在flashbuilder中成功使用過這種編碼器4.5.1? 我得到這個錯誤?通常在裝載第二張照片。任何幫助表示讚賞。jpegencoder.swc from http://last.instinct.se/graphics-and-effects/using-the-fast-asynchronous-alchemy-jpeg-encoder-in-flash/640
RangeError: Error #1506: The specified range is invalid.
at cmodule.aircall::FSM_imalloc$/start()
at cmodule.aircall::FSM_pubrealloc/work()
at cmodule.aircall::CRunner/work()
at Function/<anonymous>()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
我的代碼如下:
private var im:img;
private var jpgStream:ByteArray;
private var jpeglib:Object;
private var jpeginit:CLibInit = new CLibInit(); // get library
public function save_image(_im:img, pg:Number):void
{
var bm:BitmapData = Bitmap(_im.getChildAt(0)).bitmapData;
im = _im;
var imgData:ByteArray = bm.getPixels(bm.rect);
jpgStream = new ByteArray();
imgData.position = 0;
trace(bm == null);
var jpegQuality:Number = 40;
if (!jpeglib) {
jpeglib=jpeginit.init();
}
jpeglib.encodeAsync(encodeComplete, imgData, jpgStream, bm.width, bm.height, jpegQuality);
}
private function encodeComplete(e:Event):void {
trace("Encoding complete");
file = File.documentsDirectory.resolvePath("Pic-A-Note/" + albumName + "/object_layer_" + im.name + ".pn");
fs.open(file, FileMode.WRITE);
fs.writeBytes(jpgStream,0);
fs.close();
}
啊,這很有道理。儘管我現在自己得出這個結論,但我仍然認爲這對於那些可能會遇到這個問題的人來說是一個有用的職位。謝謝 – Tw1tCh