Hi - can anyone pass along instructions for writing a text file - ie. the content of a variable (array) to a text file for retrieval at a later time?
Thanks!
Hi - can anyone pass along instructions for writing a text file - ie. the content of a variable (array) to a text file for retrieval at a later time?
Thanks!
You would use PHP for this actually. I’m not the greatest at PHP yet, but I think it’s something like this along with some Actionscript to execute this script.
<?php
$myVar=$_POST['myFlashVar'];
$filename = "myTextFile.txt";
$raw_txt = file_get_contents($myVar);
print $raw_txt;
$fp = fopen($filename, "w");
fwrite($fp, $raw_txt);
fclose($fp);
?>
Does it have to be a text file ? Cause it’s really easy to do this with SharedObject. But you can’t open it up in notepad, but it’s easy to save, update and create.
Thanks for replying. I had a look at shared objects and would have thought the following would have worked. Any idea why it doesn’t?
test_record = SharedObject.getLocal(“filename.txt”); // open and read a text file
name_txt.text = test_record.data.tname; // set first line to a dynamic text field
address_txt.text = rest_record.data.address; // second line from text file
trace (“end”)
stop();
on to PHP
the SharedObject file is called *.sol…so try it with getLocal(“filename”);
But the code itself should work…although don’t forget to actually save it with test_record.flush(amountofbytes);
i am using your code. i am, for some reason, having trouble getting the script to write anything to the file. is this code set up to do that?
<—edit—>
nevermind, i got it.
:: Copyright KIRUPA 2024 //--