Peter Hall
Jan 23rd 2004 (changes)
The API consists of 3 new classes:
Key features of the API
If a file is loaded using the API, but then deleted by the user, the file object becomes invalid and the methods save and revert will fail and return false if the file is passed to them.
Different types of data may be stored in a file or retrieved. The type of existing files is determined automatically by Flash and the data property will always be compatible with Flash. If the encoding is "text" then the toString is called on the data before it is saved. If the encoding is "asobject" the data is serialised using the .sol file format.
The encoding is not changeable once a file is created. To change the way that a file is encoded you would have to prompt the user to overwrite it by invoking FileSystem.saveAs() like this:
FileSystem.saveAs(myFile.data, listener, myFile.name, myFile.directory, "asobject");
An object that manages loading, saving, uploading and downloading of files.
new FileSystem();
Creates a new FileSystem instance.
FileSystem.onStatus = function(){
}
public function saveAs(data:Object [,suggestedName:String [, startIn:Directory [, type:String]]]]):Boolean;
Opens a dialogue box with an OS file browser for saving. The file name field is populated with suggestedName. When the user saves a file or cancels, the saved event is triggered and a File object is passed as a property of the information object if successful.
public function save(data:Object, fileHandle:File):Boolean;
aves the data over the file specified by the fileHandle. Depending on the user's player settings, the user may be prompted before the file is overwitten.
public function open([suggestedName:String [, startIn:Directory ]]]):Boolean;
Opens a dialogue box with an OS file browser for saving. The file name field is populated with suggestedName. When the user saves a file or cancels, the saved event is triggered and a File object is passed as a property of the information object if successful.
public function revert(fileHandle:File):Boolean;
Immediately updates all properties of a file object, from the version stored on disc.
public function getBytesDownloaded():Number;
Immediately updates all properties of a file object, from the version stored on disc.
public function getBytesUploaded():Number;
Immediately updates all properties of a file object, from the version stored on disc.
An object representing a file on disc.
public var name:String;
Read-only. Name of the file.
public var data:Object;
Read-only. The data stored in the file.
public var type:String;
Read-only. Type of file. This will determine the way that a file is encoded when it is saved. Values may include "text" (default text file), "asobject" (uses .sol file format), "binary" (may be read as an array of 16bit numbers).
public var mediaType:String;
Read-only. If the file is a supported media type ("FLV", "mp3", "SWF", "JPG" or ,in Central, "gif") then the media type. Otherwise the value is null.
public var modified:Date;
Read-only. The date the file was last modified
public var created:Date;
Read-only. The date the file was created
public var readOnly:Boolean;
Read-only. true if the file is read-only
public var deleted:Boolean;
Read-only. true if the file has been deleted since the object was created
public var directory:FileSyatem.Directory;
Read-only. The containing directory of this file. This object may be used to specify this file's parent directory as the directory to start browsing in.
This object may be used to specify the directory to start browsing in when opening or "saving-as" a file.
public var deleted:Boolean;
Read-only. true if the directory has been deleted since the object was created