Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411511 Posts in 69375 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 01:07:27 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsStoring Lots of Data with flash
Pages: [1]
Print
Author Topic: Storing Lots of Data with flash  (Read 3300 times)
JasonPickering
Level 10
*****



View Profile WWW
« on: November 06, 2013, 01:39:32 PM »

Hi guys. I am not really a tech wiz. much more of an artist. So I was just wondering how people usually go about storing lots of saved data. I use shared objects, but I am thinking along the lines of stuff with huge inventories and collectibles. Like if the player had a deck with 50 different cards in it, how would you store that? assuming each card has a specific number would you just use a giant array? or storing pokemon for example. you would need to store all 150 pokemon with all their stats, and moves.

It doesnt need to be an incredibly technical answer. Even just writing out a theory would be a great help.
Logged

sharbelfs
Level 0
**



View Profile WWW
« Reply #1 on: November 06, 2013, 01:50:24 PM »

I think it depends of the kind of data you want to store.
If it is something fixed, like you said about pokemon, i would save it in a external file, xml or json, its easy to understand. And game data i am used to use shared objects, but just simples data, like the ID of the pokemon you have.
Logged

moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #2 on: November 06, 2013, 01:52:54 PM »

sounds like sharedObject  is good for the job, unless it is an online game, in which case, you'll want to keep all the data on a server somewhere
Logged

subsystems   subsystems   subsystems
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #3 on: November 07, 2013, 06:34:52 AM »

sharedObjects can go up to 100k which is more than enough for most purposes.

e.g. If you had objects that had a type (going to say 1 byte or 256 different object types) and a position (3d, so 3 floats, so 12 bytes), then you could store ~7900 (100*1024/13) objects. 

If you got more creative with how you stored data, e.g. objects are stored by roomID (lets go with Zelda 1dungeon size and say there are 64 (8x8) possible rooms) and tileID (lets go with Zelda 1 room size and say there are 176 (16x11) different possible positions), then we can store the type and position of an object in 2 bytes, allowing for 51,200 objects to be stored.
Logged
JasonPickering
Level 10
*****



View Profile WWW
« Reply #4 on: November 07, 2013, 02:00:30 PM »

Don't shared objects mostly store strings and integers. How would you go about storing  lots of data with that.?
Logged

Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #5 on: November 07, 2013, 02:14:15 PM »

Don't shared objects mostly store strings and integers. How would you go about storing  lots of data with that.?
Use a byte array, write all your data into the byte array, compress the byte array(optional), and add it to the shared object to be saved.
Logged

Attila0413
Level 1
*



View Profile WWW
« Reply #6 on: November 08, 2013, 03:05:31 PM »

For static data, like Pokemon descriptions or levels, you can use Json files and parse them when the game starts.

To save data like inventories or stats, if you want to go with XML data you can use ASAXB to easily marshal and unmarshal your objects. You then store it in a SharedObject.

Take a look here: http://www.attiliocarotenuto.com/80-articles-tutorials/flash-as3/374-flash-marshaling-and-unmarshaling-xml-data

Logged

JasonPickering
Level 10
*****



View Profile WWW
« Reply #7 on: November 12, 2013, 08:03:28 AM »

Greg: so what exactly is a byte array. I tried storing arrays before by converting them to strings then converting back to arrays on load, but it never really worked out great.

Attila0413: I use XML files a lot for storing data that never changes. I might look into that loading and saving system.
Logged

Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #8 on: November 12, 2013, 10:41:24 AM »

A byte array is an array of bytes/binary data.

Example code from a game:
Code:
public function UpdateSave():void
{
shared = SharedObject.getLocal("Retromite/ARCS", "/");

var data:ByteArray = new ByteArray();
data.endian = Endian.LITTLE_ENDIAN;
//basic vars
data.writeBoolean(DataRegistry.GameInProgress);
data.writeInt(DataRegistry.CurrentLevel);
data.writeInt(DataRegistry.Credits);
data.writeInt(DataRegistry.BaseHealth);
data.writeBoolean(DataRegistry.MUSIC_ON);
data.writeBoolean(DataRegistry.SFX_ON);
data.writeBoolean(DroneBought);
data.writeBoolean(DroneBackUpBought);
//dudes and drones
BaseDrone.Serialize(data);
BaseDude.Serialize(data);
//Mech
Mech.Serialize(data);
//shop state
MyShop.Serialize(data);

data.writeInt(DataRegistry.GameDifficultyLevel);

data.writeBoolean(HaveDoneMultiKillPrompt);
data.writeBoolean(HaveDoneWeaponTechPrompt);
data.writeBoolean(HaveDoneWeaponTech2Prompt);

shared.data.blob = data;
shared.close();
}

Anyways thats just one way to treat things, I prefer working in binary formats.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic