# Using the new save() in the file reference class

**URL:** https://forum.kirupa.com/t/using-the-new-save-in-the-file-reference-class/293030
**Category:** flash
**Created:** [July 22, 2009, 9:32am UTC](https://forum.kirupa.com/t/using-the-new-save-in-the-file-reference-class/293030 "2009-07-22T09:32:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![romit\_2034](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@romit\_2034](https://forum.kirupa.com/u/romit_2034)
#### Post date: [July 22, 2009, 9:32am UTC](https://forum.kirupa.com/t/using-the-new-save-in-the-file-reference-class/293030/1 "2009-07-22T09:32:03Z")

</div>

For a project I am working on, I allow users to drag stuff around the stage and then let them save it as JPEG. I have used the new save method from player 10. This is my code so far.

var fr:FileReference;

test\_btn.addEventListener(MouseEvent.CLICK, showPic);

function showPic(event:MouseEvent):void {

```
var bmd:BitmapData=new BitmapData(970,570);
bmd.draw(stage);
import com.adobe.images.JPGEncoder;

var jpgEncoder:JPGEncoder=new JPGEncoder(85);
var jpgStream:ByteArray=jpgEncoder.encode(bmd);

fr.save(bmd);

```

}

But when I click on the button, I get the following erro

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at homev1\_fla::MainTimeline/showPic()

What am I doing wrong, please help!
