Saving Abd Loading From Txt File
Have you ever read and write to an external file in flash? E.g if variables are contained in this text file and loaded in? I can find one way but all the variables need to be on one line in the text file like so:
VARIABLE1=00&VARIABLE2=01&
So:
VARIABLE = NAME 00 = VALUE & = SEPARATER
Bit messy though if you have loads of variables, esp if someone else wants to edit it. Any ideas? I know XML can be used, but not the easiest!
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-17-2003, 06:21 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Saving And Loading To An External File
Have you ever read and write to an external file in flash? E.g if
variables are contained in this text file and loaded in?
I can find one way but all the variables need to be on one line in the
text file like so:
VARIABLE1=00&VARIABLE2=01&
So:
VARIABLE = NAME
00 = VALUE
& = SEPARATER
Bit messy though if you have loads of variables, esp if someone else
wants to edit it.
Any ideas? I know XML can be used, but not the easiest!
Thanks
DD
Loading Then Saving Content Into A .txt File
Okay im going to try and explain this as best as possible. What I'm looking to do is have a user go to a login page (which I have) and once they make it past that, i would like the user to be able to edit and save stuff to a .txt file. The reason I want it to save the .txt file is because it is going to be used by another flash file. For instance when I was in my band the guy who did our site had it where you would login in.. you could add stuff like whats happening in the band, new CD, or up coming concerts and other stuff like that. And all we had to do is login, edit, and save it and it would be updated on the site. I hope this makes sense... sorry if it doesnt. Thanks -
Saving/Loading An Image File
Hi All,
We are working on a student test project whic basically works like a online grafitti board. People can scribble on the empty canvas and can save the created image online and can be retrieved/loaded later. We have managed to get the tools like paint brush/eraser etc working, but we have no clue how to go about 'Saving' the image from the SWF file. I would really appreciate if someone can help us with this!
Thanx
Saving And Loading In Projector File
I have created a flash projector that allows the user to drag objects around the screen. I want the user to have the ability of saving their progress and to be able to load the file and carry on from where they left off. As I am using Flash 5 I can use "FScommand save" to save and load variables. I want to know how to save the positions of the objects to a file (which will have a name specified by the user), and when loading, for them to be able to scroll through a number of saves to download the one they want. Is this possible and if so is it practical to do it in Flash. I have a reasonable knowledge of Flash but not of any other authoring environments. I also wondered if importing the file into Director and having the the Director file do the saving would work, but I don't know how to do that either. Hope someone out there can help. thanks.
Saving/loading By Shared Object File
I want to save my variables that are stored in a dynamic text field into a shared object file by clicking on my "save" button, and then load my variable data into the dynamic text fields from that shared object file using the "load" button.
When I click on the save button I dont see the shared object file being created. I had read the tutorials but cant seem to figure the thing I am doing wrong. Thats why I am including my fla file
(the fls file I made is very simple) so you can check it out. My code looks like this:
PS Could you please modify the fla file (if you find a programmnig misteke there) and attach the modified working file into your post, and tell me what I did wrong. Thanks for help!
//SAVE BUTTON
on (release) {
// create the local shared object
pos = sharedobject.getLocal("gamesave");
// save the variable number data value
pos.data.money = "money";
pos.data.week = "week";
// commit the change to disk
so.flush();
}
//LOAD BUTTON
on (release) {
// open the local shared object
pos = sharedobject.getLocal("gamesave");
// read the variable number data we saved previously
money = pos.data.money;
week = pos.data.week;
// spit it out so we can see it
trace(pos.data.money);
trace(pos.data.week);
}
Saving And Loading Variables In A .txt File (Offline)
I'm working a software we've done with Flash, but we'd want people to be able to save the variables they selected. We need them to be able to save the value of about 10 variables in a file on their desktop, and then be able to load that file again.
Is it possible to do that without having to use php or stuff like that (that's why we want to make it an offline applications so we don't have to use php to be able to save files).
I know Actionscript looks a lot like Javascript and with Javascript it's really easy to do, but all the saving functions are blocked in Flash for security reasons.
If anyone knows how to do that, to simply save and load a .txt file, please let me know. If it would be possible also to change the .txt to whatever else it would be even better. The file can still be opened in Notepad but at least it looks a bit more professionnal to have our own extension. Again in Javascript or with a .bat file it's really easy to save variables to whatever type of file, even to non existing types, it simply creates a text file with an unknown ending.
Thanks!
Edited: 01/22/2008 at 10:26:03 AM by Franz Bedlam
Loading And Saving Data From External File
http://www.kirupa.com/developer/mx/externaldata.htmi saw this tutorial in this website. But i am just wondering what if i have more than 1 records, how do i load it from the text file, and how do i save multiple records into the text file ? can anyone provide a simple guide to teach me how to do it ?? thanks a lot ~~
Loading And Saving Data From External File
http://www.kirupa.com/developer/mx/externaldata.htmi saw this tutorial in this website. But i am just wondering what if i have more than 1 records, how do i load it from the text file, and how do i save multiple records into the text file ? can anyone provide a simple guide to teach me how to do it ?? thanks a lot ~~
[AS3] Saving Generated Files & Loading File Contents
Originally Here: http://www.kirupa.com/forum/showthread.php?t=270441
Now with an explanation and source files.
When I started this I had no PHP knowledge; now i have very little, but still no experience. What this means is, it might not be the best way, but it works.
Here's the AS3 that goes in the main timeline (can be converted to a class):
Code:
_save.addEventListener( MouseEvent.CLICK, saveGame );
// _save refers to a button on stage with the instance name _save
// Listen for a mouse click that will cause function saveGame to fire
_load.addEventListener( MouseEvent.CLICK, loadGame );
// _load refers to a button on stage with the instance name _save
// Listen for a mouse click that will cause function loadGame to fire
var fileRef:FileReference;
// Declare a fileReference object.
function saveGame( event:MouseEvent ):void
{
var xmldoc:XML = <file>
<player>{name1.text}</player>
<lvl>{lvl1.selectedItem.label}</lvl>
<diff>{diff1.selectedItem.label}</diff>
</file>;
// Create an XML object with data to be saved from the user input. (diff1 and lvl1 refer
// to dropdown boxes, name1 refers to a text input).
var sendScript:URLRequest = new URLRequest( "http://yourdomain/send.php" );
// Point the request to the script that will handle the XML
sendScript.data = xmldoc;
// Set the URLRequest's data property to the XML object
sendScript.contentType = "text/xml";
// And the MIME type is set appropriately for XML.
sendScript.method = URLRequestMethod.POST;
// Set the http post method to send the data
var loader:URLLoader = new URLLoader( );
// Create a URLLoader to load the request
loader.load( sendScript );
// Load the request
navigateToURL( sendScript, "_self" );
// Now open the script in the current window (will hopefully cause
// the save dialog to appear)
}
function loadGame( event:MouseEvent ):void
{
fileRef = new FileReference();
// Instantiate fileRef
var fileFil:FileFilter = new FileFilter("XML File", "*.xml;");
// Declare and Instantiate a new fileReference object.
// This will filter the type of files that display in the browse dialog box
fileRef.addEventListener(Event.SELECT, selectHandler);
// Listen for when a user selects a file in the browse dialog
fileRef.addEventListener(Event.COMPLETE, completeHandler);
// Listen for when we're done with this ****.
try
{
var success:Boolean = fileRef.browse([fileFil]);
}
catch (error:Error)
{
// Catch any browse errors.
}
}
function selectHandler(event:Event):void
{
var ul:URLRequest = new URLRequest("http://yourdomain/upload.php");
// A file was selected, now we have to call another script (theyre explained below)
try
{
fileRef.upload(ul);
// Try to upload to it using the upload method
}
catch (error:Error)
{
// Catch any upload errors.
}
}
function completeHandler(event:Event):void
{
// Another way, exclusive to xml, would be to simply use the xml.load(url)
// Making it a hell of a lot simpler from here.
var script:URLRequest = new URLRequest( "http://yourdomain/content.php" );
// You should know by now
script.data = fileRef.name;
// The reason for this is we're sending the filename as it should appear
// on the server, to the script.
script.contentType = "text/plain";
// Nothing special about a simple string.
script.method = URLRequestMethod.POST;
// HTTP Post Method
var loader:URLLoader = new URLLoader( );
// Create a URLLoader to load the request;
loader.addEventListener( Event.COMPLETE, getResponse );
// Listen so we can handle the response
loader.load( script );
// Load the request
}
function getResponse( event:Event ):void
{
var gameData:XML = new XML( event.target.data );
// XML object gameData is set to what we echo in php
name2.text = gameData.player;
// Read <player> node
lvl2.text = gameData.lvl;
// Read <lvl> node
diff2.text = gameData.diff;
// Read <diff> node
}
Alright now for the PHP scripts.
For saving we use send.php which will read in the xml data via HTTP POST method, and will, using headers, output a file to save.
I had my own way of downloading files, however I found out that there are certain problems that will arise across different browsers. So I used a supposedly foolproof file download function, that I got from a friend. Not sure if he made it (doubt it), but that's not the point. It works, I'm happy and thank the man that made it.
PHP Code:
<?php // Read In XML from Raw Post Data.$xmldoc = $GLOBALS['HTTP_RAW_POST_DATA'];file_download($xmldoc, 'data.xml', 'text/xml');function file_download($filestring, $filename, $filetype = 'application/octet-stream'){ //Ill just leave you to download the file since the function is very long.}?>
Now for the upload script. Unfortunately, the only workaround that worked for me is uploading to a server, reading the file, then deleting the file.
I tried using a more efficient way using the temporary location of the file ( $_FILES['Filedata']['tmp_name'] ) but that didn't work. Oh well.
So this will upload the file to a directory called 'temp' and nothing more. I haven't added a filesize restriction, but you can. XML files are generally very small.
PHP Code:
<?PHP$target_path = "temp/";$target_path = $target_path . basename( $_FILES['Filedata']['name']); move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path);?>
Next we have to have a script that will run once the file upload is complete. It will simply locate the file (since we send the location from flash) then send its contents to flash, and delete the file on the server. Simple.
PHP Code:
<?php$name = $GLOBALS['HTTP_RAW_POST_DATA'];$path = "temp/";$path = $path . $name;$contents = file_get_contents($path);echo $contents;unlink($path);?>
And that's it. Post any questions, fixes, errors, better ways of doing things, etc.
Here's the zip.
Saving Data And Loading Data From A .txt File...
Hi,
I know there's a way to do it but i just couldn't get the right tutorial around..
I have read through Shared Objects but i couldn't get it work...
I just have to save my data, maybe array into .txt file and later on
retrieve from the same .txt file...
Anyone here have an example or some source code so i can have reference on it?
Thanks for the help provided....
Regards,
Lacus
Weird .as Bug -- When Saving .as File, Flash Forces 'save As', Then Creates .TMP File
has anybody seen this???
when trying to save an .as file (the file already existed), instead of it being saved, i get a 'save as' dialog from Flash
if i click 'save', i get a prompt saying the .as file already exists and do i want to overwrite it...
if i click 'yes', the file is saved and then in the directory where the .as file is saved i get something like this, Trace.as~RF11025e.TMP
the .as file in question, Trace.as, i had first saved on my PC (windows 2000), i had then saved the file to a borrowed laptop (windows xp), and now saved back to my PC...
this is when i started getting this weird bug
does anybody know what's going on???
Weird .as Bug, When Saving .as File Flash Forces 'save As', Creates .TMP File
has anybody seen this???
when trying to save an .as file (the file already existed), instead of it being saved, i get a 'save as' dialog from Flash
if i click 'save', i get a prompt saying the .as file already exists and do i want to overwrite it...
if i click 'yes', the file is saved and then in the directory where the .as file is saved i get something like this, Trace.as~RF11025e.TMP
the .as file in question, Trace.as, i had first saved on my PC (windows 2000), i had then saved the file to a borrowed laptop (windows xp), and now saved back to my PC...
this is when i started getting this weird bug
does anybody know what's going on???
Weird .as Bug, When Saving .as File Flash Forces 'save As', Creates .TMP File
has anybody seen this???
when trying to save an .as file (the file already existed), instead of it being saved, i get a 'save as' dialog from Flash
if i click 'save', i get a prompt saying the .as file already exists and do i want to overwrite it...
if i click 'yes', the file is saved and then in the directory where the .as file is saved i get something like this, Trace.as~RF11025e.TMP
the .as file in question, Trace.as, i had first saved on my PC (windows 2000), i had then saved the file to a borrowed laptop (windows xp), and now saved back to my PC...
this is when i started getting this weird bug
does anybody know what's going on???
Saving An XML File With A Certain Passed File Name To PHP
hello.
i used a kirupa tutorial to save an xml file.
AS:
var xml_file = "xmlFileName.xml";
var server_file = "phpFileName.php";
my_Xml.sendAndLoad(server_file, xml_file);
PHP:
<?php $filename = "xmlFileName.xml"; ******************
$raw_xml = file_get_contents("php://input");
$fp = fopen($filename, "w");
fwrite($fp, $raw_xml);
fclose($fp);
?>
So I need to save that my_Xml object to different files... with different file name of course. So the xmlFileName changes all the time inside my flash.
Now.. what can I change in the PHP file... so the $filename receives the value from flash?
example 1:
xml_file = "ex1.xml"
my_Xml.sendAndLoad(server_file, xml_file);
xml_file = "ex2.xml";
my_Xml.sendAndLoad(server_file, xml_file);
at the end of this... on my server must appear 2 files: ex1.xml and ex2.xml.
PS: when I run the first script, a blank IE page with the name of the php file appears... how can I get rid of it?
thank you!
Saving File On CD Rom
Is it possible to use flash on a CD ROM, like an application. So you can save simple text files and load them back into flash via a menu to choose a file from? If not can you do it in director?
Saving To A *.txt File
it's me again i am strugling to save information that a user input's to a txt file.
the txt files name is info.txt
the veriable's name is info please help.
Thanks.
Saving To A Php File
hi i have learned php a little and if you know how please tell me hou to save a veriable "name" to a *.php table "$name"
thanks Ebola
Saving To Txt File?
in my flash file i have a variable called 'total';
I want the value to be save to a txt file on the clients pc.(a cookie)
can some 1 tell me how to do this? OR do this using php or something...
Saving File From .swf
Hi How do I save something to a file from a .swf file?
For example, when you click a button, the position of the mouse cursor is saved to a .txt file.
Saving .pdf Or .doc Or Any File?
I'm trying to find a way to save files to pc on Flash.
when u click a link, instead of opening up the external file in it's program it gives u the option to "Open or Save to PC."
if i clicked on a PDF link, instead of opening the file, it'll ask if i want to save a copy to computer.
for example
"click here" (to save a copy of the PDF format to your computer)
thanks for any help
Saving A File?
hi all!
does anyone know what the code is to save a file (download a file)
for eg: i have a button that when pressed should bring up the windows download dialog "open, save, cancel"
how can i do this?
thanks
Saving To *.txt File?
hi all!
hey does anyone know how to save some text into a *.txt file?
i did it ages ago but i cant remember how i did it.
im using flash mx
any help would be great!
thanks
Saving A Txt File
Is there anyway with out swf studio to save a text file on the computer without a server?
Saving To A File
Hi. I'm in the middle of building an application in flash. But, already, I have a problem. I have no idea how to save information away to a .txt file. Does anyone know how?
Thanks in advance.
[F8] Saving To .as File
I know you can load and run external .as files that hold action script. I don't think this is possible but can you save variable values to a .as file?
[F8] Saving As An Avi File
i have made a flash movie and saved it as avi file... wen i play it in windows media player it works.. but the quality aint as good... iv tried to jiggle about with the settings when saving but still no diffrence.. how can i improve the quality of the flash file when saving as an avi file..?? thanks
Saving Changes To Swf File...
Hello,
I'm trying to see if this can be done in Flash. What I would like to do is have a graph, that can be manipulated by other users. (ex. areas that can be dragged and dropped, and boxes that display different heights when clicked). Once all of the changes have been made to the graph, I want the user to be able to save these changes for future use, if they reopen the swf file at a later date.
Can this be done?
Thanks!
Saving To A *.txt File
I use Macromedia Flash MX and I need to save a lot of information. What options do I have? Thanks!
Saving A Xml File
hi everyone
can please someone help me on this?
i want to know if someone can tell me how do i create a new xml file saving it on my hardisk or how do i add something to an existing xml file and then save it on my harddisk.
the question is how do i do this by using only flash,is it possible?
i don't wanna use asp or php or cgi or some other server-side scripts
i've searched on kirupa forums ans tutorials ans i couldn't find nothing to do this
thanks
Saving A File
i got a problem.. it's my first time to use flash mx.. i don't know how to save a file.. i tried doing the animation in the basic tutorial.. and my outcome was different from what it should have been.. there was a problem in the flow.. the text appared first then followed by the background then the background disappeared.. why did the backdround disappeared? isn't it that the background should just be there while the text was moving?
Saving Xml To File
Not sure if this is a Flash question, ASP question or a PHP question....
I have created a xml based guestbook and am having problems posting a new entry to the xml file.
I found a tutorial at http://www.kirupa.com/web/xml_guestbook.htm and so have been going off that.
I have attached my .as file which I think is ok.
The issue I am running into is that I need to use asp instead of php to physically write to the xml file. And since the tutorial only shows how to do this in php I am having trouble converting this to asp. I don't know if the issue is that flash isn't passing the data, or if my script isn't correctly requesting the data.
One problem is finding an asp equivalent to $HTTP_RAW_POST_DATA.
Any help is greatly appreciated!!
Here is the php script
PHP Code:
<?php
$file = fopen("guestbook.xml", "w+") or die("Can't open XML file");
$xmlString = $HTTP_RAW_POST_DATA;
if(!fwrite($file, $xmlString)){
print "Error writing to XML-file";
}
print $xmlString."
";
fclose($file);
?>
and here is the asp script I tried to convert the php to
Code:
DIM objFSO, xmlFile, xmlData, objFileStream
SET objFSO = Server.CreateObject("Scripting.FileSystemObject")
xmlFile = "Guestbook.xml"
xmlData = Request.Form
IF NOT objFSO.FileExists(Server.MapPath(xmlFile))THEN
'I figure it is best to error check first
Response.Write("Sorry, the file " & xmlFile & " does not exist.")
Else
'We have a file!
SET objFileStream = objFSO.OpenTextFile(Server.MapPath(xmlFile), 2)
objFileStream.Write(xmlData)
objFileStream.Close
SET objFileStream = NOTHING
'send the xml back to Flash where it is received by our receiver object
Response.Write(xmlData)
END IF
SET objFSO = NOTHING
Saving To An External .txt File
hi,
I wish to save some variables to a relative .txt, .ini (or anything else someone might care to recommend) file, so that the variable can be called into use the next time the file is opened (user name/ highscores etc...).
The project is for distribution over cd-rom, to be either installed on the host computer or run from CD with the variables stored on the host machine. I therefore can't use serverside solutions such as perl or cgi.
thanx,
geepers.
Saving To An EXTERNAL FILE
How can we make a script that saves what is on a group or just one text field in a flash movie to an external text file.
Thanks !
Saving Info To A TXT File...... How?
Ok I want to be able to load a TXT file into a flash interface then be able to make changes to the text/code/whatever (<<know how to do this) then....
click a save button and save the changes to the TXT file....
How do you save to a text file?
k
FScommand Help -- Saving In Txt File
Hi.
Can anyone refresh my failing memory on how to save variables in a txt file using FSCommand.
It was something like :
FScommand("MyFile.txt", SAVE);
Saving To A Text File
Hello,
I am trying to create a project that saves variables to a text file. Flash is able to read data in from text files, but not write to them. I understand there is a work around using the "exec" command. I have only seen it with Flash 4, does it work with Flash 5? I have seen a couple variations of this......
Code:
fscommand ("exec", "command.com" add chr(9) add "/c" add chr(9) add "echo" add chr(9) add "text3=" add TypeVar add ">c:content.txt");
Code:
fscommand ("exec", "c|: extsavesaver.exe" add chr(9) add variable1 add chr(9) add variable2);
I am looking at a couple tutorials from here, but I cannot seem to get them to work.
notepad-Emad_Ham-3431
Rune Studios Flash Tutorial
Save to disc- Guy Watson
I am on a Windows Millenium OS, wondering if that might be a problem? Anyone know of an easy to follow tutorial of how to save data to a text file?
Thx in advance
~GD~
Saving Into A Text File....HELP ME
I want save information into a text file from a .swf
I want to get flash mx to save into a .txt file.
(.swf not on the internet(just running off the computer).)
can anyone help me, source code would be helpfull....
Saving To External File
Is there a way to save an array or a variable to a txt or xml or i dont know what kind of file without using a server ?
I think that d be fun !
Regards
Me
Saving To External File
Is there a way to save an array or a variable to a txt or xml or i dont know what kind of file without using a server ?
I think that d be fun !
Regards
Me
Saving A File To Harddrive From A CD Rom
Does anyone know if its possible to save a file from a Flash created CD Rom with the click of a button?
Example: Save a PDF file to your hard-drive...
cheers,
bossanova
Saving To An External File. PLEASE HELP
Ok, I want an application that the user inputs data into a text field and when they push the "save" button, it saves it to an external file maybe in the "my documents" folder on their harddrive. Does any one know any good tutorials for that kind of thing? To save information to a file?
For Flash 5 or Flash MX.
Thanks in advance.
Saving Variables On .txt File
I need to save some variables into a text file on c:windows emp I have an old tutorial for flash4, that uses FScommand to achieve this, but in c: not c:windows emp. I tried to change the path, and although the msdos window pops-up, no file is created. How can I fix this? I attached the .fla tutorial
PS: the Flashkit "new" search sucks and blows in the same time. When it actually returns something (not very often) it is so irrelevant it makes no point wasting your time looking through the results. The old board had a perfect search function. I know my question was answered 100 times before, yet I cannot find one relevant result. Any help is appreciated
Saving A Particular Frame As A File
Hi everybody,
is it possible to save a partcular frame as a file (for example as a JPEG)? I know I can export JPEG's. But is it also possible with Actionscript?
Thx cuaris
Saving A File From Mx As Flash 4
Hi
Can any one help me? I need to save out a file from Flash MX as Flash 4 file. There is only an option there to save as Flash 5.
Would very much appreciate help.
Thanks a million
Fscommand For Saving File
hey all,
i'm working on a project that would be run in a projector.
Now, i need to save a file (with some data the user inputs) to the hard drive in a folder the user should be able to choose.
Is there a way (fscommand i guess) to have a directory browser presented to the user that would return the path of the chosen dir ?
Thanks already.
Saving Vars To A .txt File
Hey hey,
Trying to get some actionscript on the go to save a variable to an external text file. I managed to get my var to load from my external file using LoadVars.load.
Can I use the same function to .send my vars to the file?
I came across some documentation earlier that claims FScommand will not work with OS X, and I certainly couldn't get it to work.
Any advice would be appreciated.
|