well, what tool to use is all a matter of preference:
to get data into flash from other files, you will use the LoadVars() object, you can do this in a text file, and the object get all the variables, or you get the information from a database using some server language.
But what I really want is save (export) data from flash into a file.
Ie Have a visitor on my page put in his name and email address through a form, and then store this information in a text - file.
well, you have to use a server language, using a database it’s much more easy to do, but you can do with text files too, but the final result isn’t soo good, because, in text files will become too complex to keep track of all the variables, a thing that’s much easy to do in PHP, but if you want just to show the results of the entries, the text file will be enough, but all the content will be with none organization, i was doing some here in a hurry and i did something like insert a name, next line the email, two lines then the repreat of this insertion process, it’s was ok, you can then do something in php to read all the file and put this in a dinamic text field to users can read.
if you’d like something like this, tell me and i explain you how to do this.
well to do this in a text file try something like this:
in the submit buttom in flash:
on(release){
obj_save = new LoadVars();
obj_resp = new LoadVars();
obj_save.s_name = t_name.text;
obj_save.s_email = t_email.text;
obj_save.sendAndLoad(“texto.php”, obj_resp, “post”);
obj_resp.onLoad = function(){
reply.text = "Thanks! Your name is " + t_name.text + ". And your email is " + t_email.text + “!”;
}
}
in this script you crate 2 objects, 1 to connect to php and 1 to receive the replyes after the insertion is ok, i think there’s no secret here, if you don’t understand the script just ask and i explain you well.
and the php file:
<?php
$open_file = fopen(“data.txt”, “a”);
fwrite($open_file, “Name:”.$s_name."
E-mail:".$s_email."
");
fclose($open_file);
?>
here you just open a file (“data.txt”) with the option to append (“a”) in a file, if you put “w” it will overwrite the current text.
then you write in the text file the properties of the object of the connection, wich will automatically become variables of the same name in php, the last line you just close the file to don’t worry abount nothing. of course, this code can be veryt more consistent, but i just give the first step, it’s up to you finish it better, but this works good, but not so good.