Air File System Overview
Adobe AIR provides a variety of classes to support access, create and manage files and their directories. These classes are included in the Flash. filesystem package, as follows:
File
A file object represents the path of a file or directory.
Filemode
The filemode class defines some string constants used as the open () and openasync () method parameters of the filestream class. These parameters determine the file operation mode opened by the filestream object, such as writing, reading, appending, or updating.
Filestream
The filestream object is used to open files and read and write files. Once a file object reference is created, it must be passed to the filestream object for open or data operations.
Some methods of the file class are both synchronous and asynchronous:
File. copyto () and file. copytoasync ()
File. deletedirectory () and file. deletedirectoryasync ()
File. deletefile () and file. deletefileasync ()
File. getdirectorylisting () and file. getdirectorylistingasync ()
File. moveTo () and file. movetoasync ()
File. movetotrash () and file. movetotrashasync ()
Correspondingly, whether the filestream operation method is asynchronous depends on the method in which the filestream object opens the file: whether to call the open () or openasync () method.
The Asynchronous Method enables the process to run in the background. when the process is completed, the corresponding Event Notification is triggered. When an asynchronous process is executed, other code can be executed, and the synchronization method must set the addeventlistener () method of the listener, such as file or filestream.
The synchronization method is simpler. You only need to set the listener for processing, but the background process is not completed and the program will remain in the waiting state. This is especially bad for display rendering or animation, it seems that there is no response.