I referred this thread [RESOLVED] Saving a png to desktop
But it shows this error :
You cannot access the sys package while targeting js (for sys.io.FileOutput)
Here is the code I am using :
private function loadMain():Void
{
addChildViews();
mc = Assets.getMovieClip ("library:MyMovieClip");
this.addChild(mc);
var bd:BitmapData = new BitmapData(Std.int(mc.width), Std.int(mc.height), true);
bd.draw(mc);
saveImage(bd, "test.png");
}
public function saveImage(image:BitmapData, outputFile:String):Void
{
var path;
path = outputFile;
var imageData:ByteArray = image.encode(image.rect ,new PNGEncoderOptions() );
var fo:FileOutput = sys.io.File.write(path, true);
fo.writeBytes(imageData, 0, imageData.length );
fo.close();
}
How am I supposed to save image ?