Tutorial details:
Written by: Guy Watson , MX 101
Time: 40 minutes
Difficulty Level: Intermediate
Requirements: Flash MX
Topics Covered: This function is used to save a local copy of a .swf file or a local textfile. This function is used internally by the Macromedia Answers Panel as part of the update process. This function is used to save a local copy of a .swf file or a local textfile. This function is exactly the same as the undocumented Flash 5 function, dashboardSave. It can only be used within the Macromedia Authoring Environment, therefore it can only be used in .swf files that are going to be displayed inside of a panel in the authoring environment. With this function exposed, we can now create things such as self updating custom component user interfaces...
MMSave(target,filename);
This function accepts two arguments, both of which are required for the function to execute.

The first argument 'target' is a target path to a movieclip or a string variable. If you pass a target path to a movieclip and if this movieclip contains a 'fully loaded' movie, loaded using either of these methods/functions:
loadMovieNum(url,level,method);
      loadMovie(url,movieclip,method)
      movieclip.loadMovie(url,method);
Then the loaded movie will be outputted to a local file on the users hardrive, otherwise the movie that the target path resides in, is outputted to a local file. If you pass a string variable as the argument, then a textfile will be created on the users local computer containing the the valur of the string variable. This argument can be an absolute path or a relative path. Remember, that levels are also classed as movieclips, so passing _level1 as the value for the 'target' argument will save the movie which has been loaded into _level1 as a local file.

The second argument 'filename' is the filename of the outputted .swf file. This argument can only be a relative path. If you do specify a directory path, bear in mind, that the document root ( / ) as far as this function is concerned is located in the Configuration directory for your Macromedia Flash MX installation. On Windows ME, the Configuration directory is located in:
C:\Windows\Application Data\Macromedia\Flash MX\Configuration
Therefore if i wanted to create a .swf file named "guy.swf" in the root of the hardrive i could use:
MMSave(this,"../../../../../guy.swf");
The above code would save the entire movie in which the above line of code resides.

Or if i wanted to save a .swf file in the root of the Configuration directory i could use either of these lines of code:
MMSave(this,"/guy.swf");
      MMSave(this,"guy.swf");
If a file with the same filename as the value you pass for the 'filename' argument already exists, then it will be automatically over-written. This can cause serious security problems, because it could be used maliciously to over-write windows system files.

Create .swf Code Example:
//create a new movieclip
this.createEmptyMovieClip("holder",1);
//load Macromedia's site navigation into that movieclip
holder.loadMovie("http://www.macromedia.com/uber/nav/global_home.swf");
//check to see if the movie has fully loaded
//before outputting the local file
this.onEnterFrame=function(){
    if(holder.getBytesLoaded() == holder.getBytesTotal()){
        //save the movie loaded into the holder movieclip
        //as macromedia_navigation.swf in the Configuration
        //directory on the local computer
        MMSave(holder,"macromedia_navigation.swf");
        //stop checking to see if the movie has fully loaded
        delete this.onEnterFrame;
    }
};
Create textfile Code Example:
mystring="This is some text that i want to save locally";
      MMSave(mystring,"mystring.txt");
This function returns 'true' if the file was succesfully created on the users local computer, and 'false' otherwise. I assume, that this function works on all OS's because otherwise Macromedia wouldnt use it in their Answers Panel. If you are using an operating system that it doesnt work on, please let us know by posting a comment. Remember to have a good dig around for the file first, use the search tool.