Mmsave

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:WindowsApplication DataMacromediaFlash MXConfiguration

To find out the root directory where all relative file paths that the MMSave function recieves, will resolve to, use this function:

getConfigPath = function(){
var d = ASnative(302, 0)();
var i = d.lastIndexOf("/");
d = d.substr(0,i);
i = d.lastIndexOf("/")+1;
return d.substr(0,i);
}

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");

image 1

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.


Close    To Top
  • Prev Article-Flash:
  • Next Article-Flash:
  • Now: Tutorial for Web and Software Design > Flash > Basic > Flash Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction