13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

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.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with the file system<br />

File property Description<br />

creationDate The creation date of the file on the local disk.<br />

creator Obsolete—use the ext<strong>en</strong>sion property. (This property reports the Macintosh creator type of the file,<br />

which is only used in Mac OS versions prior to Mac OS X.)<br />

downloaded (AIR 2 and later) Indicates whether the refer<strong>en</strong>ced file or directory was downloaded (from the internet)<br />

or not. property is only meaningful on operating systems in which files can be flagged as downloaded:<br />

For details on these properties, see the File class <strong>en</strong>try in the ActionScript 3.0 Refer<strong>en</strong>ce for the Adobe Flash Platform.<br />

Copying and moving files<br />

Adobe AIR 1.0 and later<br />

Windows XP service pack 2 and later, and on Windows Vista<br />

Mac OS 10.5 and later<br />

exists Whether the refer<strong>en</strong>ced file or directory exists.<br />

ext<strong>en</strong>sion The file ext<strong>en</strong>sion, which is the part of the name following (and not including) the final dot ("."). If there<br />

is no dot in the fil<strong>en</strong>ame, the ext<strong>en</strong>sion is null.<br />

icon An Icon object containing the icons defined for the file.<br />

isDirectory Whether the File object refer<strong>en</strong>ce is to a directory.<br />

modificationDate The date that the file or directory on the local disk was last modified.<br />

name The name of the file or directory (including the file ext<strong>en</strong>sion, if there is one) on the local disk.<br />

nativePath The full path in the host operating system repres<strong>en</strong>tation. See “Paths of File objects” on page 667.<br />

par<strong>en</strong>t The folder that contains the folder or file repres<strong>en</strong>ted by the File object. This property is null if the File<br />

object refer<strong>en</strong>ces a file or directory in the root of the file system.<br />

size The size of the file on the local disk in bytes.<br />

type Obsolete—use the ext<strong>en</strong>sion property. (On the Macintosh, this property is the four-character file type,<br />

which is only used in Mac OS versions prior to Mac OS X.)<br />

url The URL for the file or directory. See “Paths of File objects” on page 667.<br />

The File class includes two methods for copying files or directories: copyTo() and copyToAsync(). The File class<br />

includes two methods for moving files or directories: moveTo() and moveToAsync(). The copyTo() and moveTo()<br />

methods work synchronously, and the copyToAsync() and moveToAsync() methods work asynchronously (see “AIR<br />

file basics” on page 666).<br />

To copy or move a file, you set up two File objects. One points to the file to copy or move, and it is the object that calls<br />

the copy or move method; the other points to the destination (result) path.<br />

The following copies a test.txt file from the AIR Test subdirectory of the user's docum<strong>en</strong>ts directory to a file named<br />

copy.txt in the same directory:<br />

var original:File = File.docum<strong>en</strong>tsDirectory.resolvePath("AIR Test/test.txt");<br />

var newFile:File = File.resolvePath("AIR Test/copy.txt");<br />

original.copyTo(newFile, true);<br />

In this example, the value of overwrite parameter of the copyTo() method (the second parameter) is set to true. By<br />

setting overwrite to true, an existing target file is overwritt<strong>en</strong>. This parameter is optional. If you set it to false (the<br />

default value), the operation dispatches an IOErrorEv<strong>en</strong>t ev<strong>en</strong>t if the target file exists (and the file is not copied).<br />

Last updated 6/6/2012<br />

684

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

Saved successfully!

Ooh no, something went wrong!