Flash is similar to the cookies function - SharedObject class

xiaoxiao2021-03-06  109

SharedObject class

Usability

Flash Player? 6.

Description

Shared object is quite powerful: they provide real-time data sharing between permanent objects on user computers. You can view local shared objects as "cookies".

You can use your local shared object to maintain local permanent. This is the simplest way using shared objects. For example, you can call SharedObject.getlocal () Creating a shared object in the player, such as a calculator with memory. Since the shared object is permanent in the local, Flash will save its data properties on the user's computer when the SWF file ends. The SWF file is run next time, the calculator still contains the value it has at the end of the SWF file. Alternatively, if the property of the shared object is set to NULL before the end of the SWF, the calculator does not have any previous values ​​when the Calculator is turned on next time.

To create a local shared object, use the following syntax:

// Create a local shared object

SO = SharedObject.getlocal ("foo");

Local disk space considerations

The local shared objects on the client are always permanently in the available memory and disk space.

By default, Flash can save a permanent remote sharing object that is 5K size locally. When you try to save a larger object, Flash Player displays the Local Storage dialog that allows users to allow or reject local storage for requests to access. Make sure the stage size is at least 215 x 138 pixels; this is the minimum size required for Flash to show the dialog.

If the user clicks "Allow", the object will be saved, and SharedObject.onstatus is called with the Code property of SharedObject.flush.Success; if the user clicks "Reject", the object is not saved, and uses SharedObject.flush.Failed Code Attribute calls SharedObject.onstatus.

The user can also specify a permanent local storage setting for a specific domain. The method is right-click when the SWF file is played, or hold the Control key (Macintosh), select Settings, and open the Local Storage panel.

The following table summarizes the user's disk space to choose how the shared object is mutually impact:

If the user selects "never", the object is not saved locally, and all sharedObject.flush () commands emitted for the object return false. If the user selects "Unlimited" (moving to the right), the object is saved locally until the maximum available disk space. If the user selects "None" (moving to the left), all sharedObject.flush () commands emitted for the object returns "Pending", and the player will ask the user if the user can allocate additional disk space to accommodate the object. As mentioned above. If the user selects "10 kb", "100 kb", "1 MB" or "10 MB", the object will be saved locally, and if the size of these objects do not exceed the specified space, SharedObject.flush () returns. True. If more space is required, SharedObject.flush () will return "Pending", and the player will ask the user to assign an additional disk space to accommodate the object, as described above.

In addition, if the value selected by the user is less than the amount of disk space currently used by the local permanent data, the player will warn the user to delete all local saved shared objects.

Note: Flash Player running in a creative environment has no size limit.

Summary of the method of SharedObject class

Method Description SharedObject.clear () Clears all data in the shared object and delete the shared object from disk. SharedObject.flush () Write the local permanent shared object to the local file. SharedObject.getlocal () Returns a reference to the local permanent shared object, which is only available for the current client. SharedObject.getsize () Get the current size of the shared object (in bytes). Summary of the properties of the SharedObject class

Attributes (read-only) Description SharedObject.data assigns an attribute set to the object Data property, can share and / or store these properties.

Summary of the event handler of the SharedObject class

Event Processing Function Description SharedObject.onStatus calls each time the shared object publishes an error, warning, or information notification.

Constructor of the SharedObject class

For information on creating a local shared object, see SharedObject.getlocal ().

转载请注明原文地址:https://www.9cbs.com/read-126683.html

New Post(0)