Data about computer operations, often not data operations, the most basic data manipulation is to read and save data. Flash programs often use data operations, such as loading an external file to read data. However, the ability of flash to save data is very limited. Flash 5 O'Clock We can also use Fscommond to save the external text file locally, in the flashmx era, for security considerations, Micromedia canceled the function.
Is that why we can't save the data with Flash MX? The answer is no, here I will introduce the system to the Flash MX local save external data three ways.
Method One: using the Mmsave function
Description:This is a function specifically used to save the flashmx, and Micromedia hides it for security reasons. This function also has another use: Mmsave (Loadedmcname, Savemcname), its role is to save the loaded animation into a new file, this feature can be used to convert the compressed SWF into the format of the SWF, you do not try. For Windows98 (Me) users, the default storage path is: Application Data\Macromedia\Flash mx\configuration; for Windows2000 (XP) users, The default storage path is: Documents and settings\[user]\application Data\Macromedia\Flash mx\configuration.
Usage:Mmsave (TextString, Txtfilename)
Parameters:TextString string that is used to record the content of the data to be saved
Txtfilename the text file name to save
Example:Create a dynamic text in the scene (variable name name) and set a button (instance named Send_btn). Then add the following code to the first frame.
Send_btn.onrelease = function () { Mmsave (Name, ".. /.. /.. /.. /.. /.. /data.txt "); }; |
Press "Ctrl+enter" to test to see if you can save the user name you entered in the data.txt of the C disk.
Comments: This function can only be used in the editor's debugging playback, in IE or the player can not be used.
Method Two:
using the Sharedobject object
description of the object:Sharedobject (Shared objects) can be thought of as a small database that we can use to store any data types that flash supports, such as numbers, strings, arrays, objects, and so on. Sharedobject can be divided into local (presence client) and remote (presence server side) by place of storage. A local shared object has an. sol extension. For Windows98 (Me) users, the default storage path is: Application data\macromedia\flash player\ Server domain name path \flash movie filename. swf; for Windows2000 (XP) The default storage path for users is: Documents and settings\[user]\application data\macromedia\flash player\ Server domain name path \flash movie filename. swf.
Usage:The following is an introduction to some of the most important methods and properties for local shared objects.
1) getlocal (name) method "name" parameter share object name, return reference of shared object
2) The Flush method immediately writes data to a shared object
3 The Data property accesses the channel of the shared object
All you need to know is that you can use shared objects to access external data.
Example:Set the scene by method, and enter the following code.
var user_so = sharedobject.getlocal ("user"); To establish a reference to a shared object Send_btn.onrelease = function () { With (USER_SO) { Data.name = name; Use the Data property and the Flush method to save the user name entered by the user Flush (); } }; |
Comments: 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 cookies.