Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Location of Shared Objects and Settings

Location of Shared Objects and Settings

The SharedObject class allows Macromedia Flash movies to create persistent, cookie-like data on a user’s machine. You perform this operation by calling SharedObject.getLocal. This operation stores persistent shared objects to—and later retrieves them from —a location that depends on the domain of the movie that calls getLocal, as well as (optionally) part or all of the movie’s URL.

Movies connecting to Macromedia Flash Communication Server MX can also create locally persistent shared objects by calling SharedObject.getRemote. The changes described here for getLocal also apply to locally persistent shared objects created with getRemote.

Every domain has a shared object quota. This is an allocation of the user’s disk space in which movies from that domain may store persistent shared objects. Users can change the quota for a domain at any time by choosing Settings from the Macromedia Flash Player context menu. When a movie tries to store a persistent shared object that causes Macromedia Flash Player to exceed its domain’s quota, a dialog box appears, asking the user whether to increase the domain quota.

Macromedia Flash movies connecting to Macromedia Flash Communication Server can send audio and video streams from users’ microphones and cameras by calling Microphone.get and Camera.get. When a movie does so, Flash Player displays a privacy dialog box that asks the user whether a movie can use their microphone or camera. When users reply, they can make their answer permanent. When that happens, Macromedia Flash Player records their decisions on a per-domain basis. For example, if a movie from www.mysite.com asks to use the user’s camera or microphone and the user specifies a permanent Yes for that domain, then any movie from www.mysite.com can call Microphone.get or Camera.get afterwards with any movie requests without displaying the privacy dialog box.

SharedObject, Microphone, and Camera functionality has existed since Macromedia Flash Player 6.

Applying the New Rules

In Macromedia Flash Player 6, the domains that Flash Player chooses for shared object storage, shared object quotas, and privacy settings are superdomains. For example, for a movie from www.mysite.com, Macromedia Flash Player 6 would use the superdomain mysite.com.

Macromedia Flash Player 7 chooses domains based on the version of the movie that’s playing. For movies made for Macromedia Flash Player 6, Flash Player 7 continues to use superdomains by default. For movies made for Macromedia Flash Player 7 or later, Flash Player 7 uses the exact domain of the movie by default. For example, for a Flash Player 7 movie from www.mysite.com, Flash Player 7 would use the exact domain www.mysite.com.

Choosing Which Rules to Use

You can override the defaults (superdomains for Flash Player 6 movies and exact domains for movies made for Flash Player 7 or later) by setting a new global variable called System.exactSettings. When you set this variable to true, Flash Player 7 uses exact domains; when you set it to false, Flash Player 7 uses superdomains.

Normally, these defaults should be reasonable but there are two major scenarios where you might want to change the value of System.exactSettings from its default value:

  • If you have a movie made for Macromedia Flash Player 6 that has created persistent shared objects and you want to upgrade it to a Flash Player 7 movie and you want to be able to retrieve the shared object data created by the version 6 movie, then you should set System.exactSettings = false in the Flash Player 7 movie. This forces Flash Player to read persistent shared objects from the movie’s superdomain. This is desirable because it stored them there when the Flash Player 6 movie created them.
  • If you have multiple cooperating movies, some made for Macromedia Flash Player 6 and some for Flash Player 7 (or later). If these movies need to share the data in a persistent shared object, you must ensure that they all have the same value for System.exactSettings so that Flash Player uses the same domain for all of them.

If you change the value of System.exactSettings from its default, do so very early in your movie, preferably at the beginning of Frame 1. Macromedia Flash Player will not allow you to change the value of System.exactSettings after it has used it once in a decision about shared objects or privacy settings.

It is never possible to read or write persistent shared objects from another domain. If you need to access data in another domain’s persistent shared objects, create another movie that you serve from that domain and transfer the data using ActionScript, which will probably involve calling System.security.allowDomain (described earlier in the section Granting Cross-Movie Scripting Permissions).

Comments