Actioncript 3 filereference "save" raises an error
I have some code that saves the displayable locally as an image file, but at some point it started throwing error 2174. This code is called from either a contextual click event or a 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 filereference only has one action - so there is no reason for error 2174. in case you are wondering - I am posting for flash player 10.0
UPDATE: I found it has to do with the flash player version: at 10.3 it works, and at 11.1 if it fails.
any ideas? cheers, eRez
source to share
filereference.save needs to be called from IE IE user: mouse click
If it is not, you will get this error.
Also post for version 10 or higher.
Also in the docs.
Note that due to the addition of new functionality to Flash Player, when publishing to Flash Player 10, you can only activate one of the following operations at a time: FileReference. browse (), FileReference.upload (), FileReference.download (), FileReference.load (), FileReference.save (). Otherwise, Flash Player throws a runtime error (code 2174). Use FileReference.cancel () to stop the operation in progress. This limitation applies only to Flash Player 10. Previous versions of Flash Player are not affected by this limitation when multiple operations are performed simultaneously.
source to share