03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

File<strong>Reference</strong> (flash.net.File<strong>Reference</strong>)<br />

Object<br />

|<br />

+-flash.net.File<strong>Reference</strong><br />

public class File<strong>Reference</strong><br />

extends Object<br />

The File<strong>Reference</strong> class provides a means to upload <strong>and</strong> download files between a user's<br />

computer <strong>and</strong> a server. An operating-system dialog box prompts the user to select a file to<br />

upload or a location for download. Each File<strong>Reference</strong> object refers to a single file on the<br />

user's hard disk <strong>and</strong> has properties that contain information about the file's size, type, name,<br />

creation date, modification date, <strong>and</strong> creator type (Macintosh only).<br />

File<strong>Reference</strong> instances are created in two ways:<br />

■ When you use the new operator with the File<strong>Reference</strong> constructor: var<br />

myFile<strong>Reference</strong> = new File<strong>Reference</strong>();<br />

■ When you call File<strong>Reference</strong>List.browse(), which creates an array of File<strong>Reference</strong><br />

objects<br />

During an upload operation, all of the properties of a File<strong>Reference</strong> object are populated by<br />

calls to File<strong>Reference</strong>.browse() or File<strong>Reference</strong>List.browse(). During a download<br />

operation, the name property is populated when onSelect has been invoked; all other<br />

properties are populated when onComplete has been invoked.<br />

The browse() method opens an operating-system dialog box which prompts the user to<br />

select any local file for upload. The File<strong>Reference</strong>.browse() method lets the user select a<br />

single file; the File<strong>Reference</strong>List.browse() method lets the user select multiple files. After<br />

a successful call to the browse() method, call the File<strong>Reference</strong>.upload() method to<br />

upload one file at a time. The File<strong>Reference</strong>.download() method prompts the user for a<br />

location to save the file <strong>and</strong> initiates downloading from a remote URL.<br />

The File<strong>Reference</strong> <strong>and</strong> File<strong>Reference</strong>List classes do not let you set the default file location for<br />

the dialog box generated by browse() <strong>and</strong> download() calls. The default location shown in<br />

the dialog box is the most recently browsed folder, if that location can be determined, or the<br />

desktop. The classes do not allow you to read from or write to the transferred file. They do<br />

not allow the SWF file that initiated the upload or download to access the uploaded or<br />

downloaded file or the file's location on the user's disk.<br />

File<strong>Reference</strong> (flash.net.File<strong>Reference</strong>) 563

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!