The following is a summary of some of the information on the Internet
Flex Sharedobject Introduction (Go from http://www.eb163.com/club/thread-3235-1-1.html):
The local shared object for Flash is a collection of data that is persisted on the user's machine. Flash can control these collections of data from the program, depositing or reading large amounts of information from them.
Using the Sharedobject object
Object Description: Sharedobject (Shared object) can be thought of as a small database, which we can use to store any data types supported by flash, such as numbers, strings, arrays, objects, and so on. Sharedobject by storage location can be divided into local type (presence of client) and remote type (server side). The local type shared object has an. sol extension.
Usage: The following is an introduction to some of the most important methods and properties of local shared objects.
1) getlocal (name) method "name" parameter share object name, return reference of shared object
2) Flush method immediately writes data to the shared object
3) Data property accesses the channel of the shared object data
With this knowledge, you can use shared objects to access external data.
Sharedobject.getlocal (ObjectName [, LocalPath])
Where ObjectName is the name of the shared object, LocalPath is the path where the shared object resides.
Create an object that holds data locally
var cookie:object = sharedobject.getlocal ("cookie");
Method generates a Cookie.sol file under the default path. The default size of the file cannot exceed 100k, and of course you can manage or disable your local shared object by right-clicking the Flash window and selecting settings. You can make each flash independent use of their own sharedobject, of course, you can also do a full-domain sharedobject for all the SWF to use, as long as the LocalPath assignment "/".
In Win2K and Win XP, the default path is C:\Documents and Settings\username\application Data\Macromedia\Flash player\ #SharedObjects ( Username is the user name of the machine)
Each object will have a read-only property data that stores the properties of the objects stored in the data attributes that can be shared/stored, each of which can be objects of various underlying data types (arrays, numeric booleans, and so on). Now that the cookie is stored in the Sharedobject, you can access the cookie later by accessing the Sharedobject data attribute. For example:
Cookie.data.name = "Zhang San";
Cookie.data.password = "123456";
Cookie.data.rememberPassword = true;
The write of the shared object is executed automatically when the application exits, or it can be forced to write by Cookie.flush ().
Example: Set the scene by method one, and then enter the following code.
var user_so = sharedobject.getlocal ("user"); Establish references to shared objects
Send_btn.onrelease = function () {
With (USER_SO) {
Data.name = name; Save user-entered user names with the Data property and flush method
Flush ();
}
};
Local shared objects can only save data under the default path, and the extension can only be. Sol. The effect of this method is similar to that of setting up cookies.
You only need to specify the path parameter in the Sharedobject.getlocal () method when you must share data between different flash objects, placing all flash objects that must share data in a single directory.
Sharedobject files generated after application are stored locally in the directory (go to: http://bbs.airia.cn/FLEX/thread-3956-1-1.aspx):
* Windows XP:
O for Web sites:c:\documents and settings\<user>\application data\macromedia\flash player\ #SharedObjects \< Random Code>\<domain>\<path>\<object Name>.sol
O for AIR applications, C:\Documents and settings\<user>\application data\<air application Reverse Domain NAME&G T;\local store\ #SharedObjects \<flash filename>.swf\<object Name>.sol
* Windows Vista
o c:/users/username/<user>/appdata/roaming/macromedia/flash player/#SharedObjects/<domain>/<path >/<flash Filename>.swf/<object Name>.sol
* Mac OS X:
O for Web sites, Macintosh hd:users:<user>:library:preferences:macromedia:flash Player: #SharedObjects:< Random Code>:<domain>:<path from Webserver>\<object Name>.sol
O for AIR applications, Macintosh hd:users:<username>:library:preferences:<air application Reverse Domain Name >:local Store: #SharedObjects: <flash filename>.swf\<object Name>.sol
* Linux/unix:
o/home/<user>/.macromedia/flash_player/#SharedObjects/<domain>/<path>/<flash filename>. Swf/<object Name>.sol
Use Sharedobject to implement the cookie function in Flex (go to: http://www.gold98.net/blog/article.asp?id=748):
Sharedobject provides the following methods for manipulating local objects:
Sharedobject.clear () Delete the local shared object;
Sharedobject.flush () immediately writes the shared object data to the local file;
Sharedobject.getlocal () Create or connect local shared objects;
Sharedobject.getsize () Gets the specified size data for the local shared object.
<?xml version= "1.0" encoding= "Utf-8"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml" layout= "absolute" creationcomplete= "init (event)" Bordercolor= "#FFFFFF" themecolor= "#FFFFFF" width= "height=" "backgroundcolor=" #FFFFFF "textalign=" center " Verticalalign= "Middle" horizontalalign= "center" backgroundimage= "@Embed (source= ' lt1.jpg ')" >
<mx:Script>
<! [cdata[
Import Mx.controls.Alert;
Import mx.events.FlexEvent;
Private function init (event:flexevent): void {
Create a local object that holds data s
var test:sharedobject = sharedobject.getlocal ("TestCookie");
Test.data.user = "TestUser";
TEST.DATA.PSW = "Testpwd";
Test.flush (); Commit Save
var test2:sharedobject = sharedobject.getlocal ("TestCookie");
Alert.show (Test2.data.user);
Alert.show (TEST2.DATA.PSW);
}
]]>
</mx:Script>
</mx:Application>
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/meteorlWJ/archive/2009/10/15/4675659.aspx
-----------------------------
Since the development of air, serialization has become rich all of a sudden. Saving to a local disk (such as saving a profile, etc.) can write plain files with an embedded SQLite engine. But in my opinion, Sharedobject is better, at least there are several benefits:
Store ActionScript data structures directly without having to write the serialization and deserialization algorithms yourself. Others like SQLite have to be converted between data structures and strings and have to be type checked.
The process is synchronous. Like SQLite, you have to use event snooping to read data, which increases workflow complexity asynchronously.
But there are some drawbacks:
Limited storage capacity. This is hardly a problem, and which air will store a lot of content.
Not safe enough. No one knows where to store unless it's not the average person.
I reconstructed the profile section on the company's air product and began to use Sharedobject to save the content, feeling a lot simpler. Here are a few more things to recommend:
Sharedobject View tool: An AIR Shared Object Reader
Http://blog.coursevector.com/minerva
Sharedobject Save Location:
Windows XP:
For Web sites:c:\documents and settings\<user>\application data\macromedia\flash player\ #SharedObjects \< Random Code>\<domain>\<path>\<object Name>.sol
For AIR applications, C:\Documents and settings\<user>\application data\<air application Reverse Domain Name >\local store\ #SharedObjects \<flash filename>.swf\<object Name>.sol
Windows Vista
C:/users/username/<user>/appdata/roaming/macromedia/flash player/#SharedObjects/<domain>/<path >/<flash Filename>.swf/<object Name>.sol
Mac OS X:
For Web sites, Macintosh hd:users:<user>:library:preferences:macromedia:flash Player: #SharedObjects:< Random Code>:<domain>:<path from Webserver>\<object Name>.sol
For AIR applications, Macintosh hd:users:<username>:library:preferences:<air application Reverse Domain Name >:local Store: #SharedObjects: <flash filename>.swf\<object Name>.sol
Linux/unix:
/home/<user>/.macromedia/flash_player/#SharedObjects/<domain>/<path>/<flash filename>. Swf/<object Name>.sol
EDISON.SL's signature
Article from: Flash foreignness (http://www.flashas.net/) detailed text reference: http://www.flashas.net/html/air/20090416/4049.html
-------------------------------
Deep Sharedobject----Local shared objects Collection
Sharedobject is a class for persisting data, with the ability to save data to local and remote (server).
First look at local data persistence
ObjectName is the name of the shared object, LocalPath is the path to which the shared object resides
Sharedobject.getlocal (ObjectName [, LocalPath])
The following creates a shared by object
Create an object that holds data locally
var cookie:object = sharedobject.getlocal ("cookie");
A. Sol file is generated under the default path
I use the XP system, the name is Shanghai, the default path on the machine I use is as follows:
C:\Documents and Settings\shanghai\application Data\Macromedia\Flash player\localhost
In this directory there will be some other directories, slowly find the Cookie.sol file will be found, the data is stored in this file.
Wow Gill, here I do not understand how this path is going to be,
So let's start noticing cookie.data.
Each shared object will have this attribute data, which you want to save in the database.
For example
Cookie.data.name = "sshc625";
Cookie.data.sex = "male";
Cookie.data.school = "Whut";
So I saved some of my information under this data.
This is usually the standard practice.
if (Cookie.data.name = = undefined) {
Cookie.data.name = "sshc625";
}
Path problem
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/sshcx/archive/2006/06/07/777580.aspx
===========================
Flash local Shared Object Sharedobject