all groups > flash actionscript > july 2005 >
You're in the

flash actionscript

group:

Using Javascript to write to an external file - Firefox compatibility?


Using Javascript to write to an external file - Firefox compatibility? larsiusprime
7/28/2005 9:13:56 PM
flash actionscript:
Hey everybody,

I have a question for you. You've probably read about a thousand "how do I
save files to the hard drive in flash?" questions by now. We all know the short
answer: You can't.

HOWEVER, I know you can save to an external file using a javascript FSCommand.
In fact, I've done it. Only problem is, it only works in internet explorer, not
Firefox, and I want to see if I can find a way to do that. Attached is the html
code. Let me know if you have any tips!

<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<TITLE>LevelEditor</TITLE>
<SCRIPT LANGUAGE=JScript>
<!--

//Note: the Javascript used in this html file was acquired from the
"writeToFile" tutorial shown
//in the /research subfolder. It was created by "Abates and Geijn" and their
email address is: jetta@geijn.com

var theFile = "nothing";

function setFileName(someFile) {
theFile = someFile;
}

function writeToDisk(writeString) {

var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile(theFile, true);
a.WriteLine(writeString);
a.Close();
}

//-->
</SCRIPT>

</HEAD>
<BODY bgcolor="#777777">

<SCRIPT LANGUAGE=JavaScript>
<!--
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function LevelEditor_DoFSCommand(command, args) {
var LevelEditorObj = InternetExplorer ? LevelEditor : document.LevelEditor;
//
// Place your code here...
//

if ( command == "writeToDisk" )
writeToDisk(args);
else if ( command == "setFileName" )
setFileName(args);
else
document.writeln("did not work fool");
}
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
navigator.userAgent.indexOf("Windows") != -1 &&
navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('Sub LevelEditor_FSCommand(ByVal command, ByVal args)\n');
document.write(' call LevelEditor_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</SCRIPT\> \n');
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#0099FF">
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<!--Put Some Helpful Advice In Here--><OBJECT
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve
rsion=6,0,0,0"
WIDTH="1180" HEIGHT="880" id="LevelEditor" ALIGN="">
<PARAM NAME=movie VALUE="OldLevelEditor.swf"> <PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#0099FF> <EMBED src="OldLevelEditor.swf" quality=high
bgcolor=#0099FF WIDTH="1180" HEIGHT="880" NAME="LevelEditor" ALIGN=""
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</BODY>
</HTML>
Re: Using Javascript to write to an external file - Firefox compatibility? larsiusprime
7/28/2005 9:15:20 PM
AddThis Social Bookmark Button