PDA

View Full Version : saving problems



howling shooter
August 12th, 2008, 07:05 AM
hiyar
well so far my game is going well
i have most things working, until it comes to the dreaded saving. i sat down and made a little demo to test if it would work. well the answer is a sad no. could anyone please help me, its kinda important for my game, its this or passwords so i dunno what i am gonna do. please help quickly

howling shooter
August 14th, 2008, 07:04 PM
anybody found any solution?

howling shooter
August 18th, 2008, 09:57 AM
okay i fixed the input boxes, but how do you save a dynamic text box, for some reason wont work

howling shooter
August 19th, 2008, 10:43 AM
hey, ive been trying to find out how to load a dynamic text box, for scores etc, i can load the input boxes just fine, its .text for them
but how do i load a dynamic text box?

glosrfc
August 20th, 2008, 09:31 PM
It's also .text= for dynamic text fields.

I'm not sure what you have in mind when you talk about saving...presumably you mean saving the highest score or last position in game, etc. Check out SharedObject in the help files.

bluemagica
August 21st, 2008, 05:29 AM
Err, i dont seem to understand what you exactly mean by saving? I cant open your file cause i dont have cs3, but....

Input boxes and dynamic text boxes both are just text boxes and have similar properties, including the .text property. The only difference there is that, you use input_field.text to get data "from" it, and in dynamic text boxes you will use to "send data to" it! Remember, you can also use this to send data to a input field, like giving it a default value, but the thing to keep in mind is, when you need text from user : use input field, when you want to show text to use : use dynamic text field!



If you are using As2, you can use global variables to save data during the game too! Global variables are like normal variables but with a much wider scope, means, you can call it from anywhere and everywhere from your code! it is easier to use a global variables for data that will be needed throughout the game. The values in global variables, like other variables, will be lost once you close the swf.


But sometimes, you might want to save data not only within the game, but also outside it, so that the data can still be used even when the game is closed and restarted. And this is where SharedObjects come in, you can use it to store data that the user might want to use when he runs the game again. It is commonly used to save level progress of a game!


I didn't understand your problem, so i wont go into much more details, but i thought i should just elaborate a bit on what glosRFC said. if you have trouble understanding anything else, feel free to ask!

howling shooter
August 21st, 2008, 07:21 AM
Thank you very much, i think i now understand what you mean by global variables, but i wanted to save the actual information in the dynamic text box
like when you touch an item it adds one to the dynamic text box. Which is for some reason unsaveable, when i reload the game it comes up with undefined, which confused me. i could save the file as a flash 8 file if you like?

bluemagica
August 21st, 2008, 10:46 AM
ah ok, i think i understand a bit now....but i dont know how to say it...umm...maybe.....


YOU GOT THE ENTIRE CONCEPT WRONG!!!!





The text boxes are not a store, its just a place to show text, nothing else! All values, all calculations, all data in a game, or program, are stored in "variables". Variables are the...umm...holder for all kinds of values. Your text box comes up undefined because as i said before, a variable is...well...variable, means its not constantly kept around in memory. When you load your game, all variables have already lost all their values, thus even if you associate them with the text field, they do not know what they are supposed to show.....and in as2, "undefined" is like their default value!

Dont take me the wrong way, but i think you should get a little more grip on the basics of programming before doing a entire game!

howling shooter
August 21st, 2008, 12:45 PM
ahh now i get it, and i had no problem with other stuff, got the rest a huge free roaming game totally done and polished quite well, i just always assumed that the actual text boxes were saved, okay then well atleats i know how, how would i save the variables then if i cant save the boxes?

glosrfc
August 21st, 2008, 05:53 PM
As we both said, you can use SharedObjects to save (and repopulate) the value of a variable. This includes the contents of a textfield that's previously been assigned to a variable:
http://www.permadi.com/tutorial/flashSharedObject/index.html

howling shooter
August 21st, 2008, 06:31 PM
okay, well what have i done wrong here?

glosrfc
August 21st, 2008, 07:08 PM
That wins the award for vaguest question asked.

I'm not a mindreader so I have no idea what you've done wrong...because I don't have any idea what you're trying to achieve.

Some tips:
Avoid attaching code to buttons - it makes it easier for you (and those trying to help you) to understand the code and what you're trying to do.
The SharedObject may not work in Flash's test mode. Try launching it via the Flash Player or within a browser window.
Check out the example FLA from that link. It demonstrates all you will ever need to know about SharedObject.
The help files provided with Flash also give examples of how to save textfield contents.

howling shooter
August 21st, 2008, 07:12 PM
alright, il go check out that website again now, i surpose i was a bit vague, what i meant was is there a way of getting that dynamic text box to save in that fla, ive attempted using the advise you guys posted but it seems im fumbling a bit, all i need is that one box to save and im sorted