Many applications need to store persistent data on the client computer, and Flex applications are no exception. For example, a Flex application may display a start page for new users, yet the application may give the user the option to hide the start page on subsequent visits. Though you could store that preference remotely, a more common method is to store the preference on the client side.
Flash Player security is a top priority at Adobe, and for this reason Flash Player can't write to arbitrary files on the client computer. However, Flash Player does have a designated area on the client computer where it can write to very specific files that are controlled and managed entirely by Flash Player. These files are called local shared objects, and you can use ActionScript to write to and read from these files.
Flash Player uses the
flash.net.SharedObject class to manage access to local shared object data. Although the data is stored in files on the client machine, the access to those files is controlled exclusively through the
SharedObject interface. This both simplifies working with shared objects and improves security to protect Flex application users from malicious programmers.
Note that the
SharedObject class also allows you to work with remote shared objects. For this reason, you may notice that the
SharedObject class API includes many properties and methods not discussed in this chapter. Remote shared objects allow real-time data synchronization across many clients, ...