Chapter 17. Storing Persistent Data

Introduction

Much of the data you work with in ActionScript is stored in memory while the movie is executing. When the movie is closed, the memory is released and the data is no longer available. What if you want to be able to store data between different visits to the movie? Or what if you want to be able to share data between movies running on the same client? To accomplish these feats, you’ll need to look at how you can store data outside of the Flash Player.

In ActionScript, the SharedObject class lets you to implement persistence on the client machine. There are two types of shared objects that can be created: local and remote. This chapter focuses solely on local shared objects (LSOs).

Local shared objects are similar to browser cookies in that they are stored on the client’s machine. LSOs are useful for storing the same kind of information for which cookies have traditionally been used, such as the ability for a web site to remember a user so that the user does not have to manually login during each visit. However, LSOs are more powerful than cookies because, by default, they never expire, they can store more data than cookies, they aren’t transmitted between the client and server, and they can store native ActionScript datatypes. In contrast to remote shared objects (RSOs), LSOs are available to use without any additional software involved on either the client or server.

Creating and Opening a Local Shared Object

Problem

You want to store ...

Get ActionScript 3.0 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.