Old Articles - 6 years, 6 months ago - 0 Comments

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:\Windows\Application Data\Macromedia\Flash MX\Configuration

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

function getConfigPath()
{
	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://tinyurl.com/8lvcg');

/*
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.



Note: This is an old article!

Please be aware that the content of this article may no longer be accurate and the links contained within could be broken.

Update Notifications

You can add our RSS feed to your favorite feed reader or recieve an email when a new article is posted by entering your email address below.

    Shu Player allows you to distribute your AIR Applications to users that dont have the AIR Runtime by converting them to standalone applications. Shu Player also adds more commands to do things like open external applications etc…


    If you hate the Adobe Updater like most of us, then just get rid of it.


    Want to quickly find out what version of the Flash Player a client has installed? Send them to www.playerversion.com


    Yet more pv3d goodness. Im loving this funky 3D Flash Lab, the work of Mathieu Badimon. [Update: Apparently this uses Five3D not PaperVision]


    There is an old interview with me on The FWA, its fairly long at 8 pages.


    If you do alot of travelling then it makes sense to get yourself a Priority Pass, which will get you access to over 500 airport lounges worldwide, regardless of whether your flying enconomy, business or first.


    Freelance Switch is a freelancer community with forums, jobs, daily tips and a complete 212 page e-book titled “How to be a rockstar freelancer” for sale.


    Lots of new media jobs at Creative Pool.


    BBC IPlayer is awesome, but its ashame that BBC News is still using Windows Media Player and Real video. Real player is officially badware.


More In Actionscript


More In Adobe Flash


More In Freelancing