00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS3 Sharing saved data among games

586 Views | 14 Replies
New Topic Respond to this Topic

Hello!
Basically, I want to make a series of two or more games (to publish here on Newgrounds) that will share certain saved data, just a few false-or-true variables.
Is this even possible? If it is, would please someone tell me how to do it or what to look for? Because I've been googling for days and I couldn't find anything on the subject.
Thanks in advance!

Response to AS3 Sharing saved data among games 2015-02-09 21:24:53


At 2/9/15 05:20 PM, Muja wrote: Hello!
Basically, I want to make a series of two or more games (to publish here on Newgrounds) that will share certain saved data, just a few false-or-true variables.
Is this even possible? If it is, would please someone tell me how to do it or what to look for? Because I've been googling for days and I couldn't find anything on the subject.
Thanks in advance!

I've always wondered something similar. If it was possible to know the level of the newgrounds user, there are lots of fun things you could do with that.

Response to AS3 Sharing saved data among games 2015-02-10 06:40:49


Yeah, in my case it'd serve to the purpose of making episodic games that remember your past decisions.
So, can anybody help?

At 2/9/15 09:24 PM, Barzona wrote:
At 2/9/15 05:20 PM, Muja wrote: Hello!
Basically, I want to make a series of two or more games (to publish here on Newgrounds) that will share certain saved data, just a few false-or-true variables.
Is this even possible? If it is, would please someone tell me how to do it or what to look for? Because I've been googling for days and I couldn't find anything on the subject.
Thanks in advance!
I've always wondered something similar. If it was possible to know the level of the newgrounds user, there are lots of fun things you could do with that.

Response to AS3 Sharing saved data among games 2015-02-10 08:20:42


At 2/10/15 06:40 AM, Muja wrote: Yeah, in my case it'd serve to the purpose of making episodic games that remember your past decisions.
So, can anybody help?

Would be a lot of fun to make episodic games but as far as I'm aware the only way to do what you're asking would require you to have your own servers for sending and collecting data. That's just a guess though... I do hope someone comes along and offers some input on this as I am generally curious how this is done as well.

Response to AS3 Sharing saved data among games 2015-02-10 09:35:49


At 2/9/15 05:20 PM, Muja wrote: Hello!
Basically, I want to make a series of two or more games (to publish here on Newgrounds) that will share certain saved data, just a few false-or-true variables.
Is this even possible? If it is, would please someone tell me how to do it or what to look for? Because I've been googling for days and I couldn't find anything on the subject.
Thanks in advance!

This may not be exactly what you want, but, assuming the player has Flash Player 10+, your game can prompt the player to save and load local files.
http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3.html


BBS Signature

Response to AS3 Sharing saved data among games 2015-02-10 09:36:53


Thing is, I remember I had found a way with an AS2 code to do just that... and it worked!
But I can't find anything of the sort for AS3.

Anybody? It can't be I'm the first one to think about it.....

At 2/10/15 08:20 AM, Hero101 wrote:
At 2/10/15 06:40 AM, Muja wrote: Yeah, in my case it'd serve to the purpose of making episodic games that remember your past decisions.
So, can anybody help?
Would be a lot of fun to make episodic games but as far as I'm aware the only way to do what you're asking would require you to have your own servers for sending and collecting data. That's just a guess though... I do hope someone comes along and offers some input on this as I am generally curious how this is done as well.

Response to AS3 Sharing saved data among games 2015-02-10 10:20:10


Okay, as you said that's not exactly what I wanted... but I can work with this!
Thank you a lot, that really helped!

At 2/10/15 09:35 AM, Tree-SkyLark-BCE wrote:
This may not be exactly what you want, but, assuming the player has Flash Player 10+, your game can prompt the player to save and load local files.
http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3.html

Response to AS3 Sharing saved data among games 2015-02-11 02:07:03


At 2/10/15 10:20 AM, Muja wrote: Okay, as you said that's not exactly what I wanted... but I can work with this!
Thank you a lot, that really helped!

At 2/10/15 09:35 AM, Tree-SkyLark-BCE wrote:
This may not be exactly what you want, but, assuming the player has Flash Player 10+, your game can prompt the player to save and load local files.
http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3.html

It seems you are happy with what you got but just in case, I think this might be what you want to do:

in Game1:

var Game1Save:SharedObject = SharedObject.getLocal("Game1SaveCookie");
//
//anything you want the game to save, eg. health, stats, etc.
Game1Save.flush();
//
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie");
GameShare.data.someChoice = false;
GameShare.data.someChoice2 = true;
GameShare.data.something = false;
GameShare.flush();
//

then for Game2:

var Game2Save:SharedObject = SharedObject.getLocal("Game2SaveCookie");
//
//anything you want the game to save, eg. health, stats, etc.
Game2Save.flush();
//
//loading from Game1
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie");
someChoice = GameShare.data.someChoice;
someChoice2 = GameShare.data.someChoice2;
something = GameShare.data.something;

Yeah, just saying why not try using 2 Shared Objects?

1 for the current game and 1 for sharing between games.

Response to AS3 Sharing saved data among games 2015-02-11 08:25:17


I see what you mean, and I know it works if the .swf file is physically on your computer.
But would it work when the game is hosted on a web site, like Newgrounds..? Where do the saved data go in that case?

At 2/11/15 02:07 AM, Pivot4 wrote: Yeah, just saying why not try using 2 Shared Objects?

1 for the current game and 1 for sharing between games.

Response to AS3 Sharing saved data among games 2015-02-11 22:54:30


Hey Muja, I had the same issue last week, but I think I found a solution...
My game uses AS2, but I think the getLocal function is the same in AS3

when we write

SharedObject.getLocal("game1");

it saves under one of the many cookie folders, and others cannot access it
certain browsers will even delete it once the page is shut down

but if we write

SharedObject.getLocal("game1", "/");

it saves under the same folder
and you can have other .swf access this "game1" across different websites

best of luck on the telltale Ghostbuster series!

Response to AS3 Sharing saved data among games 2015-02-11 23:07:41


BTW, where are we putting those code lines? In the .AS file? Or in the first box of actionscript on the timeline?

Also to answer @Muja , the save file will be stored at the same place, wherever the flash game is stored, since the saving destination folder is always the same ( predetermined). At least that's what I found after a little search. I may be wrong but do not think so. try it out?

Response to AS3 Sharing saved data among games 2015-02-12 01:05:20


At 2/11/15 08:25 AM, Muja wrote: I see what you mean, and I know it works if the .swf file is physically on your computer.
But would it work when the game is hosted on a web site, like Newgrounds..? Where do the saved data go in that case?

At 2/11/15 02:07 AM, Pivot4 wrote: Yeah, just saying why not try using 2 Shared Objects?

1 for the current game and 1 for sharing between games.

I just tested using ShadowWhoWalks code.

2 ideas I have from that:

idea1:
var Game1:SharedObject = SharedObject.getLocal("Game1Cookie");
var Game2:SharedObject = SharedObject.getLocal("Game2Cookie");
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie", "/");

idea2:
var Game1:SharedObject = SharedObject.getLocal("Game1Cookie", "/");
var Game2:SharedObject = SharedObject.getLocal("Game2Cookie", "/");
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie", "/");

as long as GameShare has the , "/" part it will be fine. Game1 and Game2 can be either.

Response to AS3 Sharing saved data among games 2015-02-12 06:09:50


At 2/11/15 10:54 PM, ShadowWhoWalks wrote: Hey Muja, I had the same issue last week, but I think I found a solution...
My game uses AS2, but I think the getLocal function is the same in AS3

when we write

SharedObject.getLocal("game1");

it saves under one of the many cookie folders, and others cannot access it
certain browsers will even delete it once the page is shut down

but if we write

SharedObject.getLocal("game1", "/");

it saves under the same folder
and you can have other .swf access this "game1" across different websites

best of luck on the telltale Ghostbuster series!

Thanks a lot, for the help and the support! (though the Ghostbusters tribute is finally finished and I'm now working on a totally original story)

At 2/12/15 01:05 AM, Pivot4 wrote: I just tested using ShadowWhoWalks code.

2 ideas I have from that:

idea1:
var Game1:SharedObject = SharedObject.getLocal("Game1Cookie");
var Game2:SharedObject = SharedObject.getLocal("Game2Cookie");
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie", "/");

idea2:
var Game1:SharedObject = SharedObject.getLocal("Game1Cookie", "/");
var Game2:SharedObject = SharedObject.getLocal("Game2Cookie", "/");
var GameShare:SharedObject = SharedObject.getLocal("GameShareCookie", "/");

as long as GameShare has the , "/" part it will be fine. Game1 and Game2 can be either.

If you say that you tested it and it works, I believe it!

So, thank you everyone! I think the problem's been solved!

Response to AS3 Sharing saved data among games 2015-02-12 06:19:03


At 2/12/15 06:09 AM, Muja wrote:
At 2/11/15 10:54 PM, ShadowWhoWalks wrote: as long as GameShare has the , "/" part it will be fine. Game1 and Game2 can be either.
If you say that you tested it and it works, I believe it!

So, thank you everyone! I think the problem's been solved!

This is why Newgrounds is awesome

Response to AS3 Sharing saved data among games 2015-02-12 18:05:13


At 2/12/15 06:19 AM, Aprime wrote: This is why Newgrounds is awesome

Agreed :)