Persistent Data

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 way to accomplish that is to store the preference on the client side.

Flash Player security is a top priority at Adobe, and for this reason Flash Player does not have the capability to 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

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 ...

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.