ActionScript 2.0 :: Save And Load Data To And From Variables - Reading From And Writing To Textfiles
Nov 26, 2003
I need to save and load data to and from variables. I know how to read from text-files, but not how to write to them. The text-files should work as a "database" for the high-score in a game, I cant use php cause the computer running the game wont be online all the time.
reading and writing to textfiles. I need to save and load data to and from variables. I know how to read from text-files, but not how to write to them.
The text-files should work as a "database" for the high-score in a game, I cant use php cause the computer running the game wont be online all the time.
I am wondering if it is possible to use random file access for reading and writing data to file in Actionscipt 3.0 similar to that what is in Visual Basic?
how to search through a .txt file to find a match from a input put in through flash and return which line its in the text file...ie: input, "flash" and i search through the .txt file to find a match and return what line its on?And my second part of the question, how can I use cordinates to search through a .txt file and return the data as a integer? Basically what I'm trying to do is have a list of data setup with a name and value beside it and be able to retrieve a specific value for each name, ie:
Of course I have been thinking about passing data to functions, but I can't make it work.
It is not necessary that NF1.jpg and the txts are mentioned in this code like they are now, it also could be something like a,b,c and d. So actually it is not about changing, but about being able to load different jpg's and MC's in this swf, so that I wouldnt have to use one hundred swf's!
'String(xmlData[idx].Yes' is where I'm having a problem, can't figure out the syntax for declaring the element I want to read, plus I want to read the elements inside let's say <ProceraFixedImplantBridge>. I need to add that to the code.I want to increment the counter for yes or no, and write the file back.
I am a AS newbie, so just learning AS3 (I have heard that this is a good place to start!). I am trying to read and write to an XML file.I have learned how to read an xml file but for the life of me, I can not write to the file.I have found many many tutorials that I can't seem to get to work.This is my goal... I have a small flash game that after the user wins, their user name, date, time and score get entered into the xml file. So, I just want to append the new info into the existing xml file (all the files will reside in the same directory on my server). I have all the variables ready to send.. just need the way to do it!
I have a separate AS3 flash file that shows a listing of the xml file to display the scores to the users, I have a working version of this... but I may have to change this to match how the info is being stored into the xml.
I have an Access Database (doesn't need to be Access, I can phpAdmin or mysql, whatever will work) that has a list of names. I want the user to open a Flash form and have the names load up into seperate input boxes for each name. The user can then change the names, move them, whatever, and then save the record. I want it to just overwrite the record. I donlt want create a new record. I cannot, for the life of me, figure this out. I have tried to find some tutorials but nothing makes sense. Is ASP a good way to go? I have been struggling with this for a week now.
Is there a way to do file reading and writing in flash, like using actionscript 2.0? Just like how we do it in C++. Like read variables or a string from a .txt file and write in it.
how can i save data from the game(like variables) to a file that is in my folder and read the variables from it when i open the game it will read the data from the file(save/load data to a helper file in the game's folder)is there a way to do it?(even with shared objects,as long as it use a file that is in the game's folder)
I know Flash applications cannot store data locally for security reasons, however, Macromedia has addressed this issue:
[URL]
But I don't understand that at all...
So, probably using what that link says, what's the best (easiest on the user) way to store data to a consenting user's computer? I don't mind if it has a prompt for permission, but it should not rely on too much software that nobody has (java and shockwave seem ok). The goal would be to store data across sessions, so that it would remain available if one returned to the application after closing it and going offline.
This would be useful for saving a character's HP, experience, and location variables in a game for example... possibly ending up with a .txt file that looks like:
name: Aesir level: 2 exp: 50 zone: Cave of the Poo x coordinate: 10 y coordinate: 30 gold: 5
I am currently working on the 'Flash.utils.ByteArrays' and I am using writeobject() and readobject() to write and read byte Array objects. I also understand that, the objects are serialized and de-serialized as byte arrays through AMF formatting.
Since I am trying to write the object to a device(credit card reader) that doesn't supports AMF, I was wondering if there is any other way where I can still use the writeobject() and readobject() methods but can control the creation or reading through other 'byte array ' serializing and de-serializing format options if any.
I'm writing code that takes data from mysql that's processed by a PHP script. It's actually a bit bizarre, at least to me. Anyway, here's some basic AS3 code that's moving toward what I want to do:
var loader:URLLoader = new URLLoader(); var urlRequest:URLRequest=new URLRequest("receive.php"); urlRequest.method=URLRequestMethod.GET;[code]....
For some reason, the statement "trace(evt.target.data);" produces a whole pile of garbled text before the actual stuff that it's supposed to show Because of problem #1, I've had to include a throwaway variable at the beginning, otherwise the first variable I try to pass into AS3 comes back as undefined. This causes errors when I run my flash movie in the IDE, but when I run it from the browser it doesn't seem to have any effect.But this is the strangest thing of all whenever I make any changes to the database (and subsequently try to load data from different variables), the new variables come back as undefined. For example, let's say that I add another entry to the database, and decide to load students 2, 3, and 4 instead of 1, 2, and 3. When I do that, any new data I've added comes back as undefined, even though when I view the PHP output in my browser, it looks just fine.
And now for the REALLY bizarre part: I'll copy that output, paste it into my PHP script as an echo statement, comment everything else out, and my flash movie runs fine. Even though the output from the PHP script is exactly the same, it gives me errors.
Once, I wanted to make a large RPG-game. I wanted it to be like Zelda, Diablo2 style of RPG with much Hack-and-Slash but also a little quests and a big world to explore. (a BIG game). A game needs to be programmed, so I had to choose a programming language. I chose Flash, because its easy to make graphics in it, and its not that hard, I thought. The game was planned to be a stand-alone-application that you could have on your computer and play whenever you wanted to. Much like any other game. But, this was not something I thought of in the beginning, games you make in Flash usually is web-games, right? But this RPG I wanted to make was not an online-game, and I didn't want it to be either, because it would be to big to download everytime you wanted to play it.
A RPG-game needs a save game/load game function. But Flash cannot write to external files! This was terrible! Now, its a great safety protection to make flash files not write bad things into your computer. But I need it in order to save my games! There is this way, that flash can load variables from external text files. But is there some way that I dont know about to make it save there to? One way is to make the player manually copy a mass of code (variables) from a window in the game, into the textfile. Any way to write from flash to a textfile?
I know these other two ways of "saving". 1. Using cookies to save and load. 2. Using an online database of some sort to store/load variables. But they're for online flash applications only... So I'd rather not use them.
Currently I am using SWFDOTNET libray for reading and writing swf file,which supports swf file from version 1 to 7.Is there any other open C# source lib for reading and writing swf flash which supports swf file version 8,9 and 10?
I need to know how to save and load a very small amount of variables to a computer running my swf file. It is so that a person can keep their progress in a game if they decide to close the .swf and reload it later.It has nothing to do with a server.
I need to save data to the local disk and then load it back up again as required. I'm using a local shared object to save data to and this works fine. Getting it back out again seems less straightforward. This is the code I'm using:
//Saving myLocal_so = sharedobject.getLocal("flashcookie","/"); datastring = "anyoldstuff";//sample data to save myLocal_so.data.savegame = datastring; myLocal_so.flush();
I have just started learning AS3 (2-3 weeks) and I have to say its very enjoyable!I am trying to make a function that pulls in values to save me writing 15 separate functions!I have a "street mc" which has 15 "house mc's" inside.When the user hovers over a house I want the resident to appear above the house.The house instance name is house1 and there is a mc in the library linked using the MrsRoy() class.This is my code so far:
Code:
var house1Res:MovieClip = new MrsRoy(); function resIconIn(e:MouseEvent):void{ var currentHouse = "street." + e.target.name; var currentRes = e.target.name + "Res";
[code]....
I get the error:
TypeError: Error #1006: value is not a function. at Dignity_drive_fla::MainTimeline/resIconIn()
I have my XML data loading into my SWF OK. However, is there any way to call that tag name instead of the child node number?So instead of something like this[code]...
How can I write variables into new XML? I need to take variables and write them into new XML but that I am getting is the name of the variable I am using, not the value.
I'm making something like a dynamic Picture Viewer, wich should display Pictures named by photo1, photo2, etc. dynamically from an url I give the viewer as a parameter. Thats not my problem by now, my problem is that I try to give the viewer few "parameters" through a text-file
NumberOfPictuers=12
I load this file like this
loadNumber = new loadVars(); loadNumer.onLoad = function() {
I'm making something like a dynamic Picture Viewer, wich should display Pictures named by photo1, photo2, etc. dynamically from an url I give the viewer as a parameter. Thats not my problem by now, my problem is that I try to give the viewer few "parameters" through a text-file
NumberOfPictuers=12
I load this file like this
loadNumber = new loadVars(); loadNumer.onLoad = function() {
I am trying to load a variable from data in a text file.I can read the text file fine but the variable data seemsonly to be available with in the function that reads it. I need to use the variable data outside of the function.This is the actionscript code i'm using.
var pathVars= new LoadVars(); pathVars.onLoad=function(ok) { if(ok)
I have an .SWF that is a "Share With A Friend" and the text fields are filled in and then the SWF sends the variables to sendToFriend.php and then the email is sent out.. The PHP is working fine and I have all the right codes to send that information from the SWF to to PHP, but the client wants another feature I can't figure out..
They want me to grab data from an XML and use those variables as well, because the XML will have the USER EMAIL and I need to grab the specific data from the XML and I can't find anything that does this..
I barely know where to start. Maybe a simple tutorial that doesn't just load the XML and display the content (I have found that), but rather something that loads the XML, then refers to a specific child and turns the text to a variable to get sent to PHP..
EXAMPLE XML
<client>Joe</client> <email>JOE@JOE.com</client>
How do I load the XML and directly refer to the <email> information so my PHP file can grab "JOE@JOE.com" ???
I am trying to get my PHP variables from my load.php document to my flash-document.That all works fine and I am able to get my data down to flash variables inside my function.But, I would like to be able to access this data from outside of this function which gets the data - unfortunately I cant, or.. Don't know how to. I hope that you are able to shed a light upon my problem. So here goes, this is my code:
Code: var myLoader:URLLoader = new URLLoader() myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
I am trying to load a variable from data in a text file.I can read the text file fine but the variable data seems only to be available with in the function that reads it. I need to use the variable data outside of the function.
This is the actionscript code i'm using.
var pathVars= new LoadVars(); pathVars.onLoad=function(ok) { if(ok) {
[code]....
This is where the path_var becomes undefined
trace("This is outside the function... "+path_var); pathVar1="This is outside the function... "+path_var;
I have been struggling with this all week now. I am using as3 and within my movie I have a dynamic text box that contains a score.I need this score to be written to a text file preferbly in an array that only stores the highest 5 scores.I then need values from the array to be read and displayed on another movie which will act as a high score table. e.g. I will have a dynamic text box in my high score move that will display the 1st value in the array, and then the 2nd etc.
writing/reading data to text files.Alternatively if anyone else can suggest another method for a high score table please let me know. I only need a basic high score table that runs on a users local machine as the app i am making is desined to run on individual users machines.
I have successfully written my XML from flash to the server using php. But now I need to have it write to a Windows server using either asp or asp.net. Below is my code for PHP.Have searched allot of places and found how to write text files and lines inside text files.But I use a URL variable to write my XML file name out with xml data I created in Flash as3.For simplicty I am using localhost... but really is set to my web domain.On the address line I pass: Example