when a variable is saved, is it only accessible from that swf file? or can it be accessed through another?
when a variable is saved, is it only accessible from that swf file? or can it be accessed through another?
At 12/20/05 08:20 PM, ImpotentBoy2 wrote: when a variable is saved, is it only accessible from that swf file? or can it be accessed through another?
the sol file is saved in a folder on your PC with the filename on it - eg, for a game called Chalice for which the swf is at:
D:\\_Working\ Working\ Flash\Chalice\ Chalice07.swf
the sol path will be
C:\Documents and Settings\ USERNAME\ Application Data\ Macromedia\ Flash Player\ localhost\ _Working\ Working\ Flash\ Chalice\ Chalice07.swf
So basically, unless the swf has exactly the same filename and path, no, the shared objects won't work.
As far as I know.
I havnt been to newgrounds in so long, anyway can anyone tell me whats wrong with this?
LOAD:
on (press) {
var game = SharedObject.getLocal("mitchsrpg");
if (game.data.name == undefined) {
_root.hp = 50;
_root.hp2 = 50;
_root.gotoAndStop(2);
} else {
_root.attack = game.data.attack;
_root.hp = game.data.hp;
_root.mp = game.data.mp;
_root.hp2 = game.data.hp2;
_root.mp2 = game.data.mp2;
_root.defence = game.data.defence;
_root.lvl = game.data.lvl;
_root.nextlvl = game.data.nextlvl;
_root.magic = game.data.magic;
_root.exp = game.data.exp;
_root.gotoAndStop(3);
}
}
SAVE:
on (release) {
game.data.hp = _root.hp;
game.data.hp2 = _root.hp2;
game.data.mp = _root.mp;
game.data.mp2 = _root.mp2;
game.data.attack = _root.attack;
game.data.defence = _root.defence;
game.data.lvl = _root.lvl;
game.data.nextlvl = _root.nextlvl;
game.data.magic = _root.magic;
game.data.exp = _root.exp;
game.flush();
}
You should also define game in the save button.
Unless you do _root.game = bleh on the load, which will make it accesible if you put _root on teh save, but then you'd have to load it before you save. So go with my first option
Originally it was this before I looked at the first page of this tutorail ( this didnt work either and it contains alot of extra stuff I dont know why I put it there)
LOAD:
on (press) {
game = SharedObject.getLocal("mydata");
if (game.data.name == undefined) {
_root.hp = 50;
_root.hp2 = 50;
_root.gotoAndStop(2);
} else {
attack = game.data.attack;
hp = game.data.hp;
mp = game.data.mp;
hp2 = game.data.hp2;
mp2 = game.data.mp2;
defence = game.data.defence;
lvl = game.data.lvl;
nextlvl = game.data.nextlvl;
magic = game.data.magic;
exp = game.data.exp;
_root.attack = attack;
_root.lvl = lvl;
_root.nextlvl = nextlvl;
_root.hp = hp;
_root.mp2 = mp2;
_root.mp = mp;
_root.hp2 = hp2;
_root.defence = defence;
_root.magic = magic;
_root.exp = exp;
_root.gotoAndStop(3);
}
}
SAVE:
on (press) {
game = SharedObject.getLocal("mydata");
attack = _root.attack;
lvl = _root.lvl;
nextlvl = _root.nextlvl;
defence = _root.defence;
magic = _root.magic;
exp = _root.exp;
hp = _root.hp;
hp2 = _root.hp2;
mp2 = _root.mp2;
mp = _root.mp;
game.data.hp = hp;
game.data.hp2 = hp2;
game.data.mp = mp;
game.data.mp2 = mp2;
game.data.attack = attack;
game.data.defence = defence;
game.data.lvl = lvl;
game.data.nextlvl = nextlvl;
game.data.magic = magic;
game.data.exp = exp;
game.flush();
}
That code looks functional to me. I don't sense a problem
I'm workin on something I havnt worked on in like 2 months, unless the file is currupt or flash player has changed sence then. As far as I can remeber, it used to work, and now it doesn't.
Are you using flash below 7?
I think it's like this in earlier versions
sharedObject.getlocal()
I colud be mistaken
I need help i followed the the tut but it doesn't work the output says the code is ok so i must have put everything in the right place here is the code
Timeline load code:
//Specify the save file to use
var savefile = SharedObject.getLocal("Counter");
//Grab the level and score held in the file, and assign them to variables
_root.hrs = savefile.data.hrs;
_root.min = savefile.data.min;
_root.sec = savefile.data.sec;
//If they don't exist, (ie first run), set variables to zero
if(savefile.data.score==undefined){
_root.hrse=0;
_root.min=0;
_root.sec=0;
}
Load button:
on (press){
var savefile = SharedObject.getLocal("Counter");
if(savefile.data.score==undefined){
_root.hrs=0;
_root.min=0;
_root.sec=0;
}else{
_root.score=savefile.data.score;
}
}
Save button:
on (press){
savefile.data.score = _root.hrs;
savefile.data.score=_root.min;
savefile.data.score=_root.sec;
savefile.flush();
}
Please help?
Note: The timeline code is on layer 2 and the save and load layer 1. all in 1 frame.
great post...but unfortunately i'm still can't understand. I am creating standalone shooting game. So, I want to save the game level while i playing-->>how is the code?
If i want to load the game that I saved before-->>how is the code? Can anyone explain step by step? Let me know how to do it. Please...really need help here. Please.
Wow devnish, i have never seen anyone do as much hard work as you, thankyou soo much for your help [ all of your posts have made me smarter! ] i am asking now if i can use your save / load code in my next game?
Save button:
on (press){
savefile.data.score=_root.score;
savefile.data.level=_root.level;
savefile.flush();
}
Load Button
on (press){
var savefile = SharedObject.getLocal("Savegame");
if(savefile.data.score==undefined){
_root.score=0;
}else{
_root.score=savefile.data.score;
}
}
----The tip----
DO NOT USE THE TEST MOVIE OPTION!!!!!
INSTEAD: LOCATE THE SWF FILE AND JUST OPEN IT!!!
At 3/4/06 02:00 PM, rainigul wrote: In "your game name", is your game name actually supposed to be swapped? Or is that the correct, total code?
You can swap it to whatever you want, but it has to be unique.
Sup, bitches :)
So, I've wrote a basic save game class - which will basically let you save/load data with ease (you can also do such things as check all the saved information (only if it was saved using the class though) and.. stuff like that.
Class structure:
var name:SaveGame = new SaveGame("saveFileName");
Methods:
name.saveData("_y", 275); //sets _y to 275
trace(name.loadData("_y")); //trace 275
trace(name.saveData("_y", 100)); //trace false - the saveData method will only allow you to save a unique variable
name.resaveData("_y", 100) //sets already existing variable _y to 100
trace(name.dataExists("_y")) //trace true because there is an existing var called _y
trace(name.savedData()); //trace all existing variables in order of when they were originally saved
name.clearData(true); //Clears all saved data - Boolean needed to make sure you're meaning to clear the saved data and aren't just an idiot
trace(name.sizeOf()); //traces size of the flash cookie in bytes.
Sup, bitches :)
At 3/4/06 04:10 PM, Ninja-chicken wrote: nice work liam
*blush*
Lol thanks, I've been meaning to make a save/load class for ages - turns out it only took me 20 minutes =\ I didn't have any problems or anything, most disappointing.
p.s. I just watched Nanny McPhee and it really is shite.
Sup, bitches :)
Ok Im in need of help. I made a forum with no responses =( Here is my post maybe you can help. (im too lazy to edit it =) )
Im in need of help. I looked through Denvish's forum but I am bewildered. I am making a (somewhat) game and want it to be able to save and load all of frame 2 (well mainly just the inputted text), so when poeple use it again they can continue off of it. The game is located here: http://media.putfile.com/studyguide001 Also if anyone knows a better place to host files please point one out.
Hi.
I'm using this save and load code, and all works well when i am playing the swf file.
but when i upload it and play it (embedded into a webpage) the save + load function doesnt seem to work.
Not sure if its a problem or whether its me being a dumbass.
At 3/4/06 03:12 PM, -liam- wrote: So, I've wrote a basic save game class
you did that with arrays. did you think to do it with objects?
wouldve made all the load functions simpler, i think...
At 3/30/06 02:00 PM, authorblues wrote: you did that with arrays. did you think to do it with objects?
wouldve made all the load functions simpler, i think...
Hmm, that's a good idea I guess.. I can't be bothered now though xD
Sup, bitches :)
it either didnt work or my copy of flash is fucked up.
At 6/13/06 02:50 PM, Allen1288 wrote: it either didnt work or my copy of flash is fucked up.
I'm willing to bet you did it wrong. I'd put a lot of money on that.
Sup, bitches :)
I was getting really frustrated with this, and i think many people have had the same problem-
make sure you use a button not a movieclip.
I hope that helps people, its a really simple thing but this code just wasn't working with a movieclip.
-icarus
Ok sorry for the big bump(and my ignorance for not reading the entire thread...it may answer my question somewhere...)
So my question is about saving into a new file,or something along those lines.
Say instead of saving the content into a temporary folder somewhere in the hard drive,is it possible to have a button(or automatic save) that will put the content of the Flash(Strings,Variables,etc)into a new file on a server so the content won't be lost if the owner accidentally deletes the cookies and loses their save files?
I ask because there could be a possibility of a Flash website with a log-in and passwords and such,but it would require to be saved elsewhere.
I'm not sure if this would require MySQL or not,just a question
At 4/9/07 10:29 PM, Thomas wrote: Good question
Good question, wrong thread [sorta]. That is very possible, and I only currently see the technique being used for uber-hackable high score boards in various score keeping games; rather than the awesome idea of letting a user save stuff permanently. It's an idea I've always loved, seeing as the saving method flash has is kinda jerky - the player should be able to load up his save from any PC he uses and this would allow that using a username+password scheme. I've never set up a working example because A) No need, and B) I don't really have a server.
Look into php/flash integration, sending variables to and from a server using Flash and yes MySQL would be advisable as it would be more secure and easier to manage in a long term situation.
Any questions? ;P
Sup, bitches :)
At 4/9/07 10:56 PM, liaaaam wrote:At 4/9/07 10:29 PM, Thomas wrote: Good questionGood answer
I'm probably gonna try and find out more about it later,but I have to go for now.Thanks for answer.