02-20-2011 08:40 AM
hi, I use the FileReference.save() to save img. but it throw
Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
is there other way to save file, can anyone help, thank you.
02-20-2011 09:09 AM
Can you post code that you are using to save the image?
What event listeners did you add to the class before saving?
You may have to add an event listener that listends for the IOError event to a function that does nothing (or show an alert to the user).
file_ref.addEventListener( IOErrorEvent.IO_ERROR, SaveError );
..
private function SaveError( event : IOErrorEvent ) : void
{
// do nothing
}
02-20-2011 09:29 AM
02-20-2011 09:30 AM
Hi qioxko:
Could you repost your code using the [C] icon in the toolbar that does a clean layout of the code. I cannot read it the way it is.
Thanks.
02-20-2011 09:43 AM
package
{
import com.adobe.images.JPGEncoder;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.FileReference;
[SWF(width="1024", height="600", backgroundColor="#FFFFFF", frameRate="30")]
public class Main extends Sprite
{
private var testBitMap:BitmapData;
private var bitmap:Bitmap;
private var file:FileReference;
private var jpg:JPGEncoder;
private var btnSprite:Sprite;
public function Main()
{
testBitMap = new BitmapData(320,240,false,0x000000);
bitmap = new Bitmap(testBitMap);
btnSprite = new Sprite();
btnSprite.addChild(bitmap);
addChild(btnSprite);
btnSprite.addEventListener(MouseEvent.CLICK,btnDow n);
}
private function btnDown(e:MouseEvent):void{
trace("clicked");
jpg = new JPGEncoder(100);
file = new FileReference();
file.save(jpg.encode(testBitMap),"flash.jpg");
file.addEventListener(IOErrorEvent.IO_ERROR,error) ;
}
private function error(e:IOErrorEvent):void{
}
}
}
02-20-2011 10:26 AM
You're still getting the error?
Is it just on the simulator or AIR as well?
02-20-2011 10:26 AM
Move the event listener before the save call.
02-20-2011 10:39 AM
yes, still getting the error , i test it on simulate.
02-20-2011 10:49 AM
it works when i open the swf directly, but not works on the simulate
02-20-2011 11:43 AM
People have been reporting issues with browsing on the simulator. It is probably related to that. I am certain some one will confirm the simulator issue within a day.
If it is an issue and it works in AIR, then assume that it will be fixed before the final release. If you want to make certain BB is aware of the issue, submit a bug/issue report to the BB.