Accessibility

Table of Contents

Persistent data: Saving user preferences and game scores

Points to remember while using shared objects

There are a number of points that you must remember while using shared objects for mobile phones:

  • Find a movie location: The application file needs to be saved at a location on your mobile in order for shared objects to work. If you try running your file from the message inbox, the shared object will be ineffective.
  • Don't share data between movies: The desktop version of shared objects allows multiple movies to share their persistent data. In Flash Lite, however, different SWFs cannot share data using the SharedObject class. Each file maintains its own persistent data object.
  • Consider the mobile storage capacity: Always consider the maximum storage limit of the shared object on mobile devices. Because space is limited on mobile phones, there could be situations where older data may be deleted automatically to accommodate newer data. Data storage capacities differ from device to device.
  • Delete unused data from shared objects: The Flash Lite shared object has a simple function called clear() that deletes unused data:

    mySO.clear();

    Using this function for unused data helps free space from the maximum storage limit available on mobile devices. Developers tend mostly to set SharedObject to null or undefined, but this does not delete the object and clear the space, it only nullifies the object.

  • Republishing the same movie will create multiple shared objects: When a Flash file is republished even without any alterations, the SWF is still considered modified. Thus this modified file will not be able to access the shared object created by the old published file. This is also true when two SWFs share the same name; they cannot access each other's shared object.
  • Reading and writing shared objects is slow on mobile devices: It is always advisable to use a listener with shared objects. This helps make the data available only when it is ready to use. Using data before it is prepared generally throws an undefined value.

Where to go from here

In this article I have tried to cover Flash Lite shared objects in depth. Although I have not covered the complete syntax, you can download the Flash Lite 2 CDK and refer to the Flash Lite 2 ActionScript PDF file. You can also refer to the shared object demo file from the CDK.

Meanwhile I hope my practice and knowledge proves to be a learning experience for those of you who want to use Flash Lite shared objects with games on mobile devices.