eRez
eRez

Reputation: 257

actionscript 3 filereference 'save' throws error

i have a code which saves a display object locally as an image file, but at some point it began throwing error 2174. this code is called either from context-menu click event or keyboard event.

var sourceBmd:BitmapData = new BitmapData(displayObject.width,displayObject.height);            
sourceBmd.draw(displayObject,new Matrix(displayObject.width,0,0,displayObject.height));
var jpgEncoder:JPGEncoder = new JPGEncoder(80);
var byteArray:ByteArray = jpgEncoder.encode(sourceBmd);
try
{
    filereference.save(byteArray,"posterImage.jpg");    
}
catch (e:Error)
{
    Debugging.alert("error: ",e.message);           
}

as you can see, the filereference has only a single action - so no reason for error 2174 to be thrown. in case you wonder - i'm publishing for flash player 10.0

UPDATE: i found it it has to do with the flash player version: on 10.3 it works, while on 11.1 if fails.

any ideas? cheers, eRez

Upvotes: 3

Views: 1377

Answers (3)

Grigorash Vasilij
Grigorash Vasilij

Reputation: 713

by reading through the docs, i can assume:

  1. you're running in flash player 10
  2. you don't call filereference.cancel() in cases like when the user clicks "cancel" or "close" on the dialogue box that opens; try it

Upvotes: 0

loxxy
loxxy

Reputation: 13151

Does this link solve your problem?

Also, did you try restarting flash IDE after the error occurred?

Upvotes: 0

Related Questions