Question : Actionscript 3: FileReference save error

I am trying to save data to a local file.  But I am getting the error:

Description      Resource      Path      Location      Type
1061: Call to a possibly undefined method save through a reference with static type flash.net:FileReference.      FileSave.as      /wiffleball_scorekeeper/src/admin      line 29      Flex Problem

it worked until i tried it on Flash Builder 4 Trial Version
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
{
	
import flash.events.*;
import flash.net.FileReference; 

public class FileSave
{
	[Bindable]
	public var fileRef:FileReference;
	[Bindable]
	public var stats:String;
	[Bindable]
	public var file:String;
	

	
	public function FileSave(_stats:String, _file:String)
	{
		fileRef = new FileReference();
		stats = _stats;
		file = _file;
		
	}
	
	public function saveFile():void
	{
		fileRef.addEventListener(Event.SELECT, onSaveFileSelected); 
		fileRef.save(this.stats, this.file);
		
	}

Answer : Actionscript 3: FileReference save error

There are some points to keep in mind while invoking save method of FileReference:

1. save method require Flash Player 10, so make sure you have set compiler settings to 10. (In Flex Builder, under project properties you can set it).

2. FileReference.save method can only be invoked in response to user interacted event (for e.g. click, keydown events).
So this should only be called in such event handlers.


More details: http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#save()
Random Solutions  
 
programming4us programming4us