ActionScript 3.0 Language and Components Reference [openASDocs]

FileItems

Properties | Methods | Events
FileItems by Leandro Silva

Package com.tremorvideo.airbase
Class public class FileItems
Inheritance FileItems EventDispatcher
Language Version: ActionScript 3.0
Runtime Versions: AIR 2

Simplifies working with files and directories. Actions in this Class runs asynchronously unless otherwise noted. All methods that accept a file/directory location will check the 'applicationDirectory' by default.

See also

flash.filesystem.File
com.tremorvideo.airbase.evts.FileItemsEvent



Public Properties


Property
Defined By
workerJobPath : String = null
The local path to your worker's job SWF. This is only needed if using background workers.
FileItems

Public Methods


Method
Defined By
FileItems():void
Creates a new instance of FileItems.
FileItems
appDirToStorageDir(appDir:String, storageDir:String, overwrite:Boolean = false):void
Moves data from the 'application directory' (a read-only directory) to the 'application storage directory'. The file is moved/created if it does not already exist or if the 'overwrite' param is set to true. If the file does not already exist in the 'application storage directory,' it will be created regardless of the 'overwrite' param's setting. This method is useful for cases where you need to distribute a file that can be edited by the end user (or edited by the app when installed on the end user's machine). Expects nativePaths. Runs synchronously.
FileItems
appendIt(fileData:*, path:String, sendToWorker:Boolean = false):void
Appends data to a file. The fileData param expects a string or byte array. Runs synchronously.
FileItems
copyIt(from:String, to:String, overwrite:Boolean = false, matchDirectoryStructure:Boolean = false):void
Copies file/directory to new location. Expecting nativePath.
FileItems
deleteIt(path:String):void
Deletes a file if it exists. Runs synchronously.
FileItems
existsAt(path:String):Boolean
Checks if file/directory exists.
FileItems
getFile(path:String, inAppStorageDir:Boolean = false):File
Returns a File object for a file in the 'applicationStorageDirectory.'
FileItems
getFileFromStorage(path:String):File
FileItems
listFileCancel():void
Cancels listFiles() request.
FileItems
listFiles(directory:String, includeSubdirectories:Boolean = false, includeHidden:Boolean = false, returnDirectories:Boolean = false):void
Lists all files in a specified directory.
FileItems
moveIt(from:String, to:String, overwrite:Boolean = false, matchDirectoryStructure:Boolean = false):void
Moves file/directory to new location. Expecting nativePath.
FileItems
normalizeNewlines(fileData:String):String
Returns a string with normalized newline characters specific to the OS.
FileItems
normalizeSeparator(fileData:String):String
Returns a string with normalized separator characters specific to the OS.
FileItems
openIt(path:String):void
Opens file with the default application.
FileItems
readIt(path:String, asByteArray:Boolean = false):*
Returns the file's data (as a string or byte array). Runs synchronously.
FileItems
readItAsync(path:String, asByteArray:Boolean = false):void
Gets the file's data (as a string or byte array).
FileItems
renameIt(file:File, newName:String):File
Renames a file/directory. A 'renameError' will be thrown if a file/directory with the requested name already exists in the specified location. Runs synchronously.
FileItems
tempDir(deleteOnExit:Boolean = true):File
Creates a temporary directory. If the 'deleteOnExit' param is true, the temp directory will be removed when the app is closed. Runs synchronously.
FileItems
tempFile(txt:String, deleteOnExit:Boolean = true):File
Creates a temporary file (data written as UTFBytes). If the 'deleteOnExit' param is true, the temp file will be removed when the app is closed. Runs synchronously.
FileItems
trashIt(path:String):void
Moves a file to the trash if it exists. Runs synchronously.
FileItems
writeIt(fileData:*, path:String, sendToWorker:Boolean = false):void
Creates a file. The fileData param expects a string or byte array. Runs synchronously.
FileItems

Events


Event
Summary
Defined By
asyncOpen
Dispatched once a file is opened asynchronously.
FileItems
asyncProgress
Dispatched on asynchronously progress.
FileItems
copyComplete
Dispatched when file copy is complete.
FileItems
copyIOError
Dispatched if file copy fails.
FileItems
fileError
Dispatched if an error occurs when attempting to create, append, read, or open a file.
FileItems
listCancel
Dispatched if the listFiles method is canceled. Use event.listFiles and event.totalFiles for details.
FileItems
listComplete
Dispatched when the listFiles method is complete. Use event.listFiles and event.totalFiles for details.
FileItems
listError
Dispatched if the listFiles method fails.
FileItems
moveComplete
Dispatched when file move is complete.
FileItems
moveIOError
Dispatched if file move fails.
FileItems
workerAppend
Dispatched once a worker finishes appending data to a file.
FileItems
workerWrite
Dispatched once a worker finishes writing data to a file.
FileItems

Created May 18 2015