Saving image of a movieclip or canvas

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

Here is the code I am using :

private function loadMain():Void 
	mc = Assets.getMovieClip ("library:MyMovieClip");
            var bd:BitmapData = new BitmapData(,, true);
	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 =, true);
		fo.writeBytes(imageData, 0, imageData.length );

How am I supposed to save image ?

Have you tried

It would be good if we integrated this into FileReference for HTML5, in the meantime, here’s code I used on another project:

1 Like

Thanks for sharing. Let me try this code. :slight_smile: