jpking72
asked on
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/sr c/admin line 29 Flex Problem
it worked until i tried it on Flash Builder 4 Trial Version
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/sr
it worked until i tried it on Flash Builder 4 Trial Version
{
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);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How is it going?
ASKER
i was told you can't save files locally with Flex. I was told you have to use AIR to save locally.
You can allow user to save file in Flash player 10 using AS3 (Flex either flash), it means you can't directly access local file system, but you can open the Save dialog box (System's dialog) and user can select the location.
E.g:
fileRef.save(this.stats, this.file);
// here th first parameter will be the data which will be saved, second parameter is the default file name, this method will open save dialog box and will allow user to select location, and the provided data will be saved there.
See a working example here: http://blog.flexexamples.com/2008/08/25/saving-files-locally-using-the-filereference-classs-save-method-in-flash-player-10/
E.g:
fileRef.save(this.stats, this.file);
// here th first parameter will be the data which will be saved, second parameter is the default file name, this method will open save dialog box and will allow user to select location, and the provided data will be saved there.
See a working example here: http://blog.flexexamples.com/2008/08/25/saving-files-locally-using-the-filereference-classs-save-method-in-flash-player-10/
How is it going?